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=-14.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,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 16ECFC433ED for ; Fri, 16 Apr 2021 21:15:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ABCF0613C3 for ; Fri, 16 Apr 2021 21:15:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ABCF0613C3 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 42DD06B006C; Fri, 16 Apr 2021 17:15:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4053C6B006E; Fri, 16 Apr 2021 17:15:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A50A6B0070; Fri, 16 Apr 2021 17:15:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id 0C9826B006C for ; Fri, 16 Apr 2021 17:15:29 -0400 (EDT) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id BF420180327F0 for ; Fri, 16 Apr 2021 21:15:28 +0000 (UTC) X-FDA: 78039486336.26.D62BFF0 Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by imf03.hostedemail.com (Postfix) with ESMTP id AE8E4C0007C6 for ; Fri, 16 Apr 2021 21:15:24 +0000 (UTC) Received: by mail-io1-f53.google.com with SMTP id f15so20269504iob.5 for ; Fri, 16 Apr 2021 14:15:28 -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=+W0hnQa1CjbAyTNkhndY0LLW1aGekZ/YUtZf1MUBxVw=; b=DH2PrVAtDezpk+rkyD1txBuOo+iJJeN2ZcLoyHLnWEEUKS+XpdfubYbJi/U85nkM51 dACDd+5O9x21MnZzVyoknldJKWMrh0s878DavvKI2NvEuTBd1Voa9YzYrkY9vlYFg02n FLe6mEpdopadTxXD8KcIW3yfXXBwKn9+CF75kCtmtI3Sz3TAfNmd2yDp7D6caMXuFKWC 9gNc24oZUK5Y5sC8mJkci6aTzE5NBMPxQJeL55Jgn5AqGM3sY4GEfmlG7v8BmKCcSJRX UzN0FJCGdQ2WNMo4bTXyThNZWT5uqfEoKc4yBKSDaUHDcnN4qqlw3csEuCUwEAaUwliX zOOQ== X-Gm-Message-State: AOAM533EdaUpMPpCUiBmdJZmHusLWdJEc56a0vR5szk0TLy452U+cGZ7 nZ7wHlxkYfnxYhV455DCL0c= X-Google-Smtp-Source: ABdhPJwySTTp9aY4FHoEo5+4VzJHcJ4gs/hwoO7Tsr3Q4kn0nmLjqLR5pdwJZb2AZCaL8PyOujadyw== X-Received: by 2002:a02:a616:: with SMTP id c22mr5275872jam.129.1618607727888; Fri, 16 Apr 2021 14:15:27 -0700 (PDT) Received: from google.com (243.199.238.35.bc.googleusercontent.com. [35.238.199.243]) by smtp.gmail.com with ESMTPSA id s1sm852425iov.52.2021.04.16.14.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 14:15:27 -0700 (PDT) Date: Fri, 16 Apr 2021 21:15:25 +0000 From: Dennis Zhou To: Roman Gushchin Cc: Tejun Heo , Christoph Lameter , Andrew Morton , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 5/6] percpu: factor out pcpu_check_chunk_hint() Message-ID: References: <20210408035736.883861-1-guro@fb.com> <20210408035736.883861-6-guro@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210408035736.883861-6-guro@fb.com> X-Stat-Signature: sjebemay6dzxdecgnswux5abhi5d35kp X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: AE8E4C0007C6 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf03; identity=mailfrom; envelope-from=""; helo=mail-io1-f53.google.com; client-ip=209.85.166.53 X-HE-DKIM-Result: none/none X-HE-Tag: 1618607724-587411 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, On Wed, Apr 07, 2021 at 08:57:35PM -0700, Roman Gushchin wrote: > Factor out the pcpu_check_chunk_hint() helper, which will be useful > in the future. The new function checks if the allocation can likely > fit the given chunk. > > Signed-off-by: Roman Gushchin > --- > mm/percpu.c | 30 +++++++++++++++++++++--------- > 1 file changed, 21 insertions(+), 9 deletions(-) > > diff --git a/mm/percpu.c b/mm/percpu.c > index e20119668c42..357fd6994278 100644 > --- a/mm/percpu.c > +++ b/mm/percpu.c > @@ -306,6 +306,26 @@ static unsigned long pcpu_block_off_to_off(int index, int off) > return index * PCPU_BITMAP_BLOCK_BITS + off; > } > > +/** > + * pcpu_check_chunk_hint - check that allocation can fit a chunk > + * @chunk_md: chunk's block nit for consistency: @block: block of interest > + * @bits: size of request in allocation units > + * @align: alignment of area (max PAGE_SIZE) > + * > + * Check to see if the allocation can fit in the chunk's contig hint. > + * This is an optimization to prevent scanning by assuming if it > + * cannot fit in the global hint, there is memory pressure and creating > + * a new chunk would happen soon. > + */ It occurred to me, That I converged block_md and chunk_md to be the same object as 1 is just a degenerative case of the other. Can we rename this to be pcpu_check_block_hint() and have it take in pcpu_block_md? > +static bool pcpu_check_chunk_hint(struct pcpu_block_md *chunk_md, int bits, > + size_t align) > +{ > + int bit_off = ALIGN(chunk_md->contig_hint_start, align) - > + chunk_md->contig_hint_start; > + > + return bit_off + bits <= chunk_md->contig_hint; > +} > + > /* > * pcpu_next_hint - determine which hint to use > * @block: block of interest > @@ -1065,15 +1085,7 @@ static int pcpu_find_block_fit(struct pcpu_chunk *chunk, int alloc_bits, > struct pcpu_block_md *chunk_md = &chunk->chunk_md; > int bit_off, bits, next_off; > > - /* > - * Check to see if the allocation can fit in the chunk's contig hint. > - * This is an optimization to prevent scanning by assuming if it > - * cannot fit in the global hint, there is memory pressure and creating > - * a new chunk would happen soon. > - */ > - bit_off = ALIGN(chunk_md->contig_hint_start, align) - > - chunk_md->contig_hint_start; > - if (bit_off + alloc_bits > chunk_md->contig_hint) > + if (!pcpu_check_chunk_hint(chunk_md, alloc_bits, align)) > return -1; > > bit_off = pcpu_next_hint(chunk_md, alloc_bits); > -- > 2.30.2 > Thanks, Dennis