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.9 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,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 321C6C433E1 for ; Tue, 19 May 2020 20:20:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DD936206C3 for ; Tue, 19 May 2020 20:20:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="GMxJtQEs" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DD936206C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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 505BE80010; Tue, 19 May 2020 16:20:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DC1C900003; Tue, 19 May 2020 16:20:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C92D80010; Tue, 19 May 2020 16:20:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0028.hostedemail.com [216.40.44.28]) by kanga.kvack.org (Postfix) with ESMTP id 2397F900003 for ; Tue, 19 May 2020 16:20:28 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id D6C5A2A87 for ; Tue, 19 May 2020 20:20:27 +0000 (UTC) X-FDA: 76834586094.08.feast04_5b49dbd1d3d04 X-HE-Tag: feast04_5b49dbd1d3d04 X-Filterd-Recvd-Size: 4776 Received: from mx0b-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 May 2020 20:20:27 +0000 (UTC) Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 04JKKDx9015285 for ; Tue, 19 May 2020 13:20:26 -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=GMxJtQEscqJ9BXyYPGcvP7uMRjBN66PHLZoHHTMt4bNQ9a9wuPTSSgAb0SRb2OWtLT/t RpXKPRb1r+lio180hfygVaPahI9UQWtgBiBFpwxka9dqzGByiT5cK8bo/9LjKAI5tUg7 Y2Ki7i7vWr1ZV7DWhvpAKKXsqjMfBuRQQdQ= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 312dwqvh49-8 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 19 May 2020 13:20:26 -0700 Received: from intmgw001.06.prn3.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1847.3; Tue, 19 May 2020 13:20:23 -0700 Received: by devvm1291.vll0.facebook.com (Postfix, from userid 111017) id AC65A12947D9; Tue, 19 May 2020 13:18:08 -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 RFC 1/5] percpu: return number of released bytes from pcpu_free_area() Date: Tue, 19 May 2020 13:18:02 -0700 Message-ID: <20200519201806.2308480-2-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200519201806.2308480-1-guro@fb.com> References: <20200519201806.2308480-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.676 definitions=2020-05-19_09:2020-05-19,2020-05-19 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 suspectscore=2 spamscore=0 mlxlogscore=999 mlxscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 phishscore=0 cotscore=-2147483648 lowpriorityscore=0 adultscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2005190174 X-FB-Internal: deliver 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