From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BD54C433E1 for ; Thu, 28 May 2020 23:30:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E77C02078C for ; Thu, 28 May 2020 23:30:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="mN85xGrH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E77C02078C 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 1EDB9800B6; Thu, 28 May 2020 19:30:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 19D9980010; Thu, 28 May 2020 19:30:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 08C52800B6; Thu, 28 May 2020 19:30:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id E559F80010 for ; Thu, 28 May 2020 19:30:17 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A930C180AD820 for ; Thu, 28 May 2020 23:30:17 +0000 (UTC) X-FDA: 76867723674.22.group73_59d2d36f6c831 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id 95B0F18038E68 for ; Thu, 28 May 2020 23:30:17 +0000 (UTC) X-HE-Tag: group73_59d2d36f6c831 X-Filterd-Recvd-Size: 4759 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Thu, 28 May 2020 23:30:17 +0000 (UTC) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.16.0.42/8.16.0.42) with SMTP id 04SNH0J8021981 for ; Thu, 28 May 2020 16:30:16 -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=fhtB5ZWQ6jMx0FEaLLsxbR6W7EbN/9OSiRNOpbjzI2I=; b=mN85xGrHVs0o3/icWtTUl+BvQEoBVb25Il9PoTb5C6D93mMGB5KQ3dQ3W+mUSIlVdnYy oPx+O5m8US1Jlk7P5gPYGIlUnmslE2WT3+xknHq5gFq7JoS5Y6SFDKD9VnLs6vAABj1q PJ1IsmOsC4eVwW+0g/EseDh7ECkF6pkcV6I= Received: from maileast.thefacebook.com ([163.114.130.16]) by m0001303.ppops.net with ESMTP id 319ybhvuyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 28 May 2020 16:30:16 -0700 Received: from intmgw001.41.prn1.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Thu, 28 May 2020 16:30:15 -0700 Received: by devvm1291.vll0.facebook.com (Postfix, from userid 111017) id 7DB8916E595D; Thu, 28 May 2020 16:25:10 -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 v1 1/5] percpu: return number of released bytes from pcpu_free_area() Date: Thu, 28 May 2020 16:25:04 -0700 Message-ID: <20200528232508.1132382-2-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200528232508.1132382-1-guro@fb.com> References: <20200528232508.1132382-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.216,18.0.687 definitions=2020-05-28_08:2020-05-28,2020-05-28 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 clxscore=1015 priorityscore=1501 cotscore=-2147483648 spamscore=0 impostorscore=0 bulkscore=0 suspectscore=2 malwarescore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005280148 X-FB-Internal: deliver X-Rspamd-Queue-Id: 95B0F18038E68 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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 --- 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 *chu= nk, 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 =3D &chunk->chunk_md; - int bit_off, bits, end, oslot; + int bit_off, bits, end, oslot, freed; =20 lockdep_assert_held(&pcpu_lock); pcpu_stats_area_dealloc(chunk); @@ -1230,8 +1233,10 @@ static void pcpu_free_area(struct pcpu_chunk *chun= k, int off) bits =3D end - bit_off; bitmap_clear(chunk->alloc_map, bit_off, bits); =20 + freed =3D bits * PCPU_MIN_ALLOC_SIZE; + /* update metadata */ - chunk->free_bytes +=3D bits * PCPU_MIN_ALLOC_SIZE; + chunk->free_bytes +=3D freed; =20 /* update first free bit */ chunk_md->first_free =3D 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); =20 pcpu_chunk_relocate(chunk, oslot); + + return freed; } =20 static void pcpu_init_md_block(struct pcpu_block_md *block, int nr_bits) --=20 2.25.4