From patchwork Mon Jun 8 23:08:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Gushchin X-Patchwork-Id: 11594133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B80D0138C for ; Mon, 8 Jun 2020 23:10:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 82ECC2100A for ; Mon, 8 Jun 2020 23:10:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="Jw4De9V5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 82ECC2100A Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=fb.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B41296B0008; Mon, 8 Jun 2020 19:10:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AF24C6B000D; Mon, 8 Jun 2020 19:10:42 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E0EB6B000E; Mon, 8 Jun 2020 19:10:42 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 80BF16B0008 for ; Mon, 8 Jun 2020 19:10:42 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 43006804930E for ; Mon, 8 Jun 2020 23:10:42 +0000 (UTC) X-FDA: 76907591124.25.talk73_3f1216e26dbd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id 18608180889CF for ; Mon, 8 Jun 2020 23:10:42 +0000 (UTC) X-Spam-Summary: 2,0,0,724119ab807429cc,d41d8cd98f00b204,prvs=3428c3563a=guro@fb.com,,RULES_HIT:41:355:379:541:560:800:960:965:966:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1437:1513:1515:1516:1518:1521:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2892:2895:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3872:4321:4385:4390:4395:5007:6261:6653:8603:10004:10400:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13069:13311:13357:14096:14097:14181:14394:14721:21080:21450:21451:21627:21990:30034:30054:30064:30070:30075,0,RBL:67.231.153.30:@fb.com:.lbl8.mailshell.net-64.201.201.201 62.12.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: talk73_3f1216e26dbd X-Filterd-Recvd-Size: 4812 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Mon, 8 Jun 2020 23:10:41 +0000 (UTC) Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 058NAZcS002290 for ; Mon, 8 Jun 2020 16:10:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=/V8jlYrtrAZx/4M+Yvb5XPaEETGmQNxopoGELAItQGo=; b=Jw4De9V5lQAH6SXRX3qCmtog7Yp81XFxmmwqONYtPoH9s/dAar/f0fPB4THw9mu+qlAA 3B8+Dxsxl8Z3R72gTpmpuvUzSnKm8yZU0UhR5Cc++EciYibzdTNgnHHY8O10MQtKp1C3 8Fe5NlQ+HUtguqxjuSWXZHFkGM1I/2qSTBM= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com with ESMTP id 31g8nkt76u-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 08 Jun 2020 16:10:40 -0700 Received: from intmgw002.06.prn3.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:11d::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 8 Jun 2020 16:10:36 -0700 Received: by devvm1291.vll0.facebook.com (Postfix, from userid 111017) id 534991D8FFD4; Mon, 8 Jun 2020 16:08:28 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1291.vll0.facebook.com To: Andrew Morton , Dennis Zhou , Tejun Heo , Christoph Lameter CC: Johannes Weiner , Michal Hocko , Shakeel Butt , , , , Roman Gushchin Smtp-Origin-Cluster: vll0c01 Subject: [PATCH v2 1/5] percpu: return number of released bytes from pcpu_free_area() Date: Mon, 8 Jun 2020 16:08:15 -0700 Message-ID: <20200608230819.832349-2-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200608230819.832349-1-guro@fb.com> References: <20200608230819.832349-1-guro@fb.com> MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-06-08_18:2020-06-08,2020-06-08 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 impostorscore=0 phishscore=0 clxscore=1015 mlxscore=0 priorityscore=1501 malwarescore=0 spamscore=0 mlxlogscore=999 suspectscore=2 cotscore=-2147483648 lowpriorityscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006080161 X-FB-Internal: deliver X-Rspamd-Queue-Id: 18608180889CF X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: To implement accounting of percpu memory we need the information about the size of freed object. Return it from pcpu_free_area(). Signed-off-by: Roman Gushchin Acked-by: Dennis Zhou --- mm/percpu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 696367b18222..aa36b78d45a6 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -1211,11 +1211,14 @@ static int pcpu_alloc_area(struct pcpu_chunk *chunk, int alloc_bits, * * This function determines the size of an allocation to free using * the boundary bitmap and clears the allocation map. + * + * RETURNS: + * Number of freed bytes. */ -static void pcpu_free_area(struct pcpu_chunk *chunk, int off) +static int pcpu_free_area(struct pcpu_chunk *chunk, int off) { struct pcpu_block_md *chunk_md = &chunk->chunk_md; - int bit_off, bits, end, oslot; + int bit_off, bits, end, oslot, freed; lockdep_assert_held(&pcpu_lock); pcpu_stats_area_dealloc(chunk); @@ -1230,8 +1233,10 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) bits = end - bit_off; bitmap_clear(chunk->alloc_map, bit_off, bits); + freed = bits * PCPU_MIN_ALLOC_SIZE; + /* update metadata */ - chunk->free_bytes += bits * PCPU_MIN_ALLOC_SIZE; + chunk->free_bytes += freed; /* update first free bit */ chunk_md->first_free = min(chunk_md->first_free, bit_off); @@ -1239,6 +1244,8 @@ static void pcpu_free_area(struct pcpu_chunk *chunk, int off) pcpu_block_update_hint_free(chunk, bit_off, bits); pcpu_chunk_relocate(chunk, oslot); + + return freed; } static void pcpu_init_md_block(struct pcpu_block_md *block, int nr_bits)