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=-10.0 required=3.0 tests=BAYES_00,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS 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 2876BC43461 for ; Thu, 3 Sep 2020 15:46:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC7EA20775 for ; Thu, 3 Sep 2020 15:46:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC7EA20775 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 7489E6B0002; Thu, 3 Sep 2020 11:46:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F7C96B0003; Thu, 3 Sep 2020 11:46:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60DED6B0037; Thu, 3 Sep 2020 11:46:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 485EA6B0002 for ; Thu, 3 Sep 2020 11:46:31 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CDD603499 for ; Thu, 3 Sep 2020 15:46:30 +0000 (UTC) X-FDA: 77222177340.23.moon06_210fa3a270aa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id A052C37609 for ; Thu, 3 Sep 2020 15:46:30 +0000 (UTC) X-HE-Tag: moon06_210fa3a270aa X-Filterd-Recvd-Size: 4403 Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 15:46:30 +0000 (UTC) Received: by mail-qv1-f67.google.com with SMTP id cr8so1514959qvb.10 for ; Thu, 03 Sep 2020 08:46:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mSAXUUSnUBvb/oaJhQhywsGLLh+znmIIBtfUNj/5Vcg=; b=CiJ0a0ob8duTGXpqfVb9wBAWCq0w1U/KvlsaSAxMxoCJ7nOdP3mGR9UYObuvVRvkHH 2OGzGAX4iCcVQO78yFm/nCNFml8F11SvBlVJ/bjyI8lHHUVkwo54Hr2O60Ux5JQwY9MT +qP2qa+Y6eeSTXzaJJm2zYZd5Qfq/faFQZWv+X8wj4X3vKl/idiWZW7/UUHrcsx1asI5 xdCDMkLww4cLNWwBgVt2xSPubBTRixYOCvVj4NScwx1PDbVfNNJWqkt+kPEITE3Ixs2b dv8bLpBC736O1+THmtqHTazRIZRPoNpe0XGe1zLpS0uwFQNbZqVNuUubh574Fy8FaiQG OoBA== X-Gm-Message-State: AOAM533TmdupQzhjuisDzZeamL2WT/q0Kb99SRpUd/EyUlTafJexqCNm oS3xznG+vA7RbqIynsEC2EUEc3KgKXA= X-Google-Smtp-Source: ABdhPJwjZmDRxE3BXkcez+kQTagnfQYz/BeZKv673N2BQZbD/elIBQwAifC9+GDYlks9UfalfDhxlg== X-Received: by 2002:a67:fe81:: with SMTP id b1mr1998399vsr.5.1599147988407; Thu, 03 Sep 2020 08:46:28 -0700 (PDT) Received: from google.com (239.145.196.35.bc.googleusercontent.com. [35.196.145.239]) by smtp.gmail.com with ESMTPSA id n16sm469833vsr.17.2020.09.03.08.46.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 08:46:27 -0700 (PDT) Date: Thu, 3 Sep 2020 15:46:26 +0000 From: Dennis Zhou To: Vlastimil Babka Cc: mcsmonk , linux-mm@kvack.org, Mike Rapoport , Dennis Zhou , Tejun Heo Subject: Re: [PATCH] mm/percpu.c: Modify calculation of size of populated bitmap of chunk for memory allocation Message-ID: <20200903154626.GA1665298@google.com> References: <20200903124116.1668-1-mcsmonk@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: A052C37609 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: Hello Vlastimil and Sunghyun, On Thu, Sep 03, 2020 at 03:46:33PM +0200, Vlastimil Babka wrote: > On 9/3/20 2:41 PM, mcsmonk wrote: > > From: Sunghyun Jin > > > > Variable populated, which is a member of struct pcpu_chunk, is used as a > > unit of size of unsigned long. > > However, size of populated is miscounted. So, I fix this minor part. > > +CC folks who touched it last > Thanks for CCing me. > Nice find! Did you observe e.g. a panic that can be used in the commit log? Or > were we always lucky thanks to alignment? Well that is indeed awkward. Luckily the first chunk is a bit special and only holds 7 dynamic pages. Additionally, the allocation rounds to SMP_CACHE_BYTES so that would give us 8 bytes to play with as struct pcpu_chunk is 120 bytes. So, while technically (wrong) the 1 byte was sufficient and the additional buffer is why at least I never got a panic report to today. > Is there perhaps a commit that introduced the bug and we can use it as Fixes:? > My brief look suggests 8ab16c43ea79 ("percpu: change the number of pages marked > in the first_chunk pop bitmap") > That is the right commit. I'll pick this up and add the fixes line. > Thanks! > Thanks, Dennis > > Signed-off-by: Sunghyun Jin > > --- > > mm/percpu.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/mm/percpu.c b/mm/percpu.c > > index f4709629e6de..1ed1a349eab8 100644 > > --- a/mm/percpu.c > > +++ b/mm/percpu.c > > @@ -1316,7 +1316,7 @@ static struct pcpu_chunk * __init pcpu_alloc_first_chunk(unsigned long tmp_addr, > > > > /* allocate chunk */ > > alloc_size = sizeof(struct pcpu_chunk) + > > - BITS_TO_LONGS(region_size >> PAGE_SHIFT); > > + BITS_TO_LONGS(region_size >> PAGE_SHIFT) * sizeof(unsigned long); > > chunk = memblock_alloc(alloc_size, SMP_CACHE_BYTES); > > if (!chunk) > > panic("%s: Failed to allocate %zu bytes\n", __func__, > > >