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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBEE7C38A2D for ; Tue, 25 Oct 2022 03:48:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7763080008; Mon, 24 Oct 2022 23:48:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7261180007; Mon, 24 Oct 2022 23:48:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5D06280008; Mon, 24 Oct 2022 23:48:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 49E9980007 for ; Mon, 24 Oct 2022 23:48:04 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 2068D4074A for ; Tue, 25 Oct 2022 03:48:04 +0000 (UTC) X-FDA: 80058088488.16.C87B641 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf30.hostedemail.com (Postfix) with ESMTP id B66DB80015 for ; Tue, 25 Oct 2022 03:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666669683; 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=PYgidL+/ri8mEQCVHJ40l8Y7OFSEYg6EaOK4xr7Faag=; b=FXHzYQLdNPUHirV2RNfiOg7xF0mIUoMx8SCPvWxzDqfupMdvrJ0CcYOX2Lw+05jD93T+Yx lGwiC1fXbnrpVMt+ycqORnt2rFVrdIIW2IAByDPqSjwDlGNDzTOi9bbinDt2cE8SWitt1m efbuflx6/s741A21UDOCXBbDXYzD60s= 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-58-03pYwOQ6MRWC0gtGzitq9A-1; Mon, 24 Oct 2022 23:47:56 -0400 X-MC-Unique: 03pYwOQ6MRWC0gtGzitq9A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AFA241C05AFA; Tue, 25 Oct 2022 03:47:55 +0000 (UTC) Received: from localhost (ovpn-12-35.pek2.redhat.com [10.72.12.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B474111F3B6; Tue, 25 Oct 2022 03:47:54 +0000 (UTC) Date: Tue, 25 Oct 2022 11:47:51 +0800 From: Baoquan He To: Dennis Zhou Cc: linux-kernel@vger.kernel.org, Tejun Heo , Christoph Lameter , Andrew Morton , linux-mm@kvack.org Subject: Re: [PATCH 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1666669683; 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=PYgidL+/ri8mEQCVHJ40l8Y7OFSEYg6EaOK4xr7Faag=; b=Kd6gjgB9Z25v9Lk2VHgnRVvdj2hWDIEvfAkJIYfGX+mYmmQmIXN0OgZwopRUB0JIneTand 3stkvE1Vi5fBIbBG6DK8mNHVtDz2Ixk2ONNp12xEKHi0ELOMOuZdxTtzY5OW5Hyoc1tO/a SgvjxPijIYj+Rf428JzYAFMcBn94iNU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXHzYQLd; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.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=1666669683; a=rsa-sha256; cv=none; b=WSP2Mdb+y9YYjumcutbEsE5lqDef2DmPK8CYvFZ1bQbD6ihAokUbgi7yTdqH39pRAQpiT3 iyKSEVzhmQcalG0zxau2utzhg3m071Y1rS84mduoJHBfGTwymZT5zjFt1aXRnoD5AHAJGk PjSwLwq0Lsaehy4NP7+QNhueq6W3xZU= X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B66DB80015 X-Rspam-User: Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FXHzYQLd; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Stat-Signature: 9tckt4y3j6fqubexmrqbrx4cc5x3hb98 X-HE-Tag: 1666669683-353126 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: On 10/24/22 at 09:56am, Dennis Zhou wrote: > On Mon, Oct 24, 2022 at 04:14:31PM +0800, Baoquan He wrote: > > 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 account it > > here. The number of pages will be subtracted with pcpu_chunk_populated() > > when populating pages. > > > > Adding code comment to make that more understandable. > > > > Signed-off-by: Baoquan He > > --- > > mm/percpu.c | 14 +++++++++++--- > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > diff --git a/mm/percpu.c b/mm/percpu.c > > index a8121302a79c..09e407338573 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 subtracted with > > + * pcpu_chunk_populated() when populating pages. > > + */ > > if (nr_empty_pages) > > pcpu_update_empty_pages(chunk, -nr_empty_pages); > > > > -- > > 2.34.1 > > > > Heh, that's a little more subtle than I remember it being. > > Acked-by: Dennis Zhou Thanks for reviewing, Dennis. When I rechecked the code comment, I realized I had said the opposite in v1 about the newly added code comment. It subtracts the nr_empty_pop_pages in pcpu_block_update_hint_alloc() whether it's atomic allocation or not. If non atomic case, the number will be added back in pcpu_chunk_populated() when populating pages. I have updated and resent v2, sorry for the mistake. Thanks Baoquan