From patchwork Tue Oct 25 03:45:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13018443 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDDC6C38A2D for ; Tue, 25 Oct 2022 03:45:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5CA6580008; Mon, 24 Oct 2022 23:45:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 57A7380007; Mon, 24 Oct 2022 23:45:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4423A80008; Mon, 24 Oct 2022 23:45:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 36B2180007 for ; Mon, 24 Oct 2022 23:45:26 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0682F12088F for ; Tue, 25 Oct 2022 03:45:26 +0000 (UTC) X-FDA: 80058081852.09.84BF152 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 370BC14000A for ; Tue, 25 Oct 2022 03:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666669524; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2yyOON7LbQAPpeXWsN3XLmEjn+mjaX4CQWaI9pF4woU=; b=QA/f3BVey6lyLOPpIIkU7ayoAegHEtLnYC/JxvEDjas/jQriSwF0kmzq71Kn5zrpph6aPY G9amfGQd0idC4eSC1H8yOVzyNhaTD9WJ27pE06CMvxS+WDkEvNDFLqG68jeTC4CEvMl0BV 796Mm5cqyjaOjD18QbTinANFUYEvcks= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-155-7uFxu-DhM2uK7vANZRugxQ-1; Mon, 24 Oct 2022 23:45:21 -0400 X-MC-Unique: 7uFxu-DhM2uK7vANZRugxQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CD4341C0514E; Tue, 25 Oct 2022 03:45:20 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D642020290A2; Tue, 25 Oct 2022 03:45:19 +0000 (UTC) Date: Tue, 25 Oct 2022 11:45:16 +0800 From: Baoquan He To: linux-kernel@vger.kernel.org Cc: Dennis Zhou , Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org Subject: [PATCH v2 4/8] mm/percpu: add comment to state the empty populated pages accounting Message-ID: References: <20221024081435.204970-1-bhe@redhat.com> <20221024081435.204970-5-bhe@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221024081435.204970-5-bhe@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666669525; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=2yyOON7LbQAPpeXWsN3XLmEjn+mjaX4CQWaI9pF4woU=; b=pitvqdeY2qLChbf12d/GbD4OB7xCY9LYPZn/Otw72HWTdhhgVYyE9QLeVE6V3Uw1BqgoYP woYSP/9Pe8ZG5gyzhpbMcTkpT6rWSlGONg+mYICC31c/qBlyAr9zpxiwDj0Zi10wvL+EdW xg9juUp+0lirxcAKNCqJAAi+rQRL2qw= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="QA/f3BVe"; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1666669525; a=rsa-sha256; cv=none; b=KE7CuSEuLc0P2ZyH6oQWZLVavTzk6YEc//F9GqeSG0oLjN1Uem7y2zwfcJzeMcBgzrFrCi O3ps8HOExB91J3CekBHlkcPIEuCf1w8Cuvr6VJGAXSxCKItzqNW8J0+iFav6xjyIZLPGq9 n3GLizPHLGNx2m6PE1d6+ZL36C1Ric4= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 370BC14000A X-Rspam-User: Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="QA/f3BVe"; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: p4fynsstzcqf8gcd5mzfdxykksor5xg6 X-HE-Tag: 1666669525-586557 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: When allocating an area from a chunk, pcpu_block_update_hint_alloc() is called to update chunk metadata, including chunk's and global nr_empty_pop_pages. However, if the allocation is not atomic, some blocks may not be populated with pages yet, while we still subtract the number here. The number of pages will be added back with pcpu_chunk_populated() when populating pages. Adding code comment to make that more understandable. Signed-off-by: Baoquan He --- v1->v2: - I said the opposite in the v1 code comment. It subtracts the nr_empty_pop_pages whether it's atomic allocation or not. In non atomic case, the number will be added back in pcpu_chunk_populated() when populating pages. mm/percpu.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/mm/percpu.c b/mm/percpu.c index 68d5ba61c935..786c7a2eb4f0 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -831,13 +831,15 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, /* * Update s_block. - * block->first_free must be updated if the allocation takes its place. - * If the allocation breaks the contig_hint, a scan is required to - * restore this hint. */ if (s_block->contig_hint == PCPU_BITMAP_BLOCK_BITS) nr_empty_pages++; + /* + * block->first_free must be updated if the allocation takes its place. + * If the allocation breaks the contig_hint, a scan is required to + * restore this hint. + */ if (s_off == s_block->first_free) s_block->first_free = find_next_zero_bit( pcpu_index_alloc_map(chunk, s_index), @@ -912,6 +914,12 @@ static void pcpu_block_update_hint_alloc(struct pcpu_chunk *chunk, int bit_off, } } + /* + * If the allocation is not atomic, some blocks may not be + * populated with pages, while we account it here. The number + * of pages will be added back with pcpu_chunk_populated() + * when populating pages. + */ if (nr_empty_pages) pcpu_update_empty_pages(chunk, -nr_empty_pages);