Message ID | 20230617070955.1751393-1-linmiaohe@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1844024vqr; Sat, 17 Jun 2023 01:05:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ67axpH3VF9SbUUzF8Kyw8u6V5dV+7sxseWz4WhwJpfgSP4tTDxBlQcdzMsSYQ9rJrHtjew X-Received: by 2002:a05:6808:14d0:b0:39a:b787:1ae5 with SMTP id f16-20020a05680814d000b0039ab7871ae5mr5729618oiw.48.1686989148746; Sat, 17 Jun 2023 01:05:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686989148; cv=none; d=google.com; s=arc-20160816; b=hzSYopr0qBP8nUNVwWZEh5aykz9DdvhH454aCsdhv3t8LxEXHYN85SKq7JgTuKcHQ7 5WPBmqcVLp+uUPsXGjnl1+8obJomLdiZo65pY1sKYNv9//ALoBroOmTW9Fcbg9PC69E9 vI5G1Zig+rtvo7Vfs8lZnZnHD6lMU+yyouj6H+o/9iDVbr7Rw5MwZ+nuPtJqcoAt7moh HNSo5hTsLMpQwd4qkM3gmFkOZIhqPjeqS1YvKMIJWWtzczOYjSUPhb4b8UJPlzpPaA3t QeFD89raAzi31I9D3s8cAPXgcc3hXftULhym9izX7GdSvYuoBXfOz+keujw58Ys/OVvB uJlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=dNT+H/qVYP5V/hUdTGN9CPXuCR5FZq8kqaosGz5dRV4=; b=j0Qp3c0USP7k9Si+CkPY8S32LCg2yhJGdLgyr5Atm9ZZKwY8m+Mq8tuHlh4s9wvLUj 2NxGBEQMLJgGJwz316ksFv9v7EczHL7p559EZdVGNYhuXA9mmbWz5w7GzoCmMXYARHpp bsoic2PWoWktN+11Wx3PMlFq5hbGodGrvM4jf4UaXIz9P8OO+ALvq/M5PyVTEnz30tOV aiwjHmUkW2FCwpg+3b32pN9CsyyYBGUJn65ArXvwp0PmgKJkeG+7HzwFmpZu3Y7RxJMl 4Xf7QSGPDyu+czngu2ftl9lXOhSSK5a+g7Khq93wBFxUa0x0UEqK5HvwDbvHt5EPCn66 oxIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a170902ecc700b001b39e50bfdasi13738589plh.638.2023.06.17.01.05.35; Sat, 17 Jun 2023 01:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234017AbjFQHKf (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Sat, 17 Jun 2023 03:10:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231929AbjFQHKd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 17 Jun 2023 03:10:33 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 50417211D for <linux-kernel@vger.kernel.org>; Sat, 17 Jun 2023 00:10:31 -0700 (PDT) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4QjnD73DZ4ztQVr; Sat, 17 Jun 2023 15:07:51 +0800 (CST) Received: from huawei.com (10.175.104.170) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Sat, 17 Jun 2023 15:10:23 +0800 From: Miaohe Lin <linmiaohe@huawei.com> To: <akpm@linux-foundation.org>, <rppt@kernel.org>, <tglx@linutronix.de>, <mingo@redhat.com> CC: <peterz@infradead.org>, <dvhart@infradead.org>, <dave@stgolabs.net>, <andrealmeid@igalia.com>, <linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>, <linmiaohe@huawei.com> Subject: [PATCH] mm/mm_init.c: remove obsolete macro HASH_SMALL Date: Sat, 17 Jun 2023 15:09:55 +0800 Message-ID: <20230617070955.1751393-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.170] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768936334033999586?= X-GMAIL-MSGID: =?utf-8?q?1768936334033999586?= |
Series |
mm/mm_init.c: remove obsolete macro HASH_SMALL
|
|
Commit Message
Miaohe Lin
June 17, 2023, 7:09 a.m. UTC
HASH_SMALL only works when parameter numentries is 0. But the sole caller
futex_init() never calls alloc_large_system_hash() with numentries set to
0. So HASH_SMALL is obsolete and remove it.
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
---
include/linux/memblock.h | 2 --
kernel/futex/core.c | 3 +--
mm/mm_init.c | 10 +---------
3 files changed, 2 insertions(+), 13 deletions(-)
Comments
On Sat, Jun 17, 2023 at 03:09:55PM +0800, Miaohe Lin wrote: > HASH_SMALL only works when parameter numentries is 0. But the sole caller > futex_init() never calls alloc_large_system_hash() with numentries set to > 0. Doesn't it? What happens when CONFIG_BASE_SMALL is set? > So HASH_SMALL is obsolete and remove it. > Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > --- > include/linux/memblock.h | 2 -- > kernel/futex/core.c | 3 +-- > mm/mm_init.c | 10 +--------- > 3 files changed, 2 insertions(+), 13 deletions(-) > > diff --git a/include/linux/memblock.h b/include/linux/memblock.h > index f71ff9f0ec81..346d80809517 100644 > --- a/include/linux/memblock.h > +++ b/include/linux/memblock.h > @@ -581,8 +581,6 @@ extern void *alloc_large_system_hash(const char *tablename, > unsigned long high_limit); > > #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ > -#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min > - * shift passed via *_hash_shift */ > #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ > > /* Only NUMA needs hash distribution. 64bit NUMA architectures have > diff --git a/kernel/futex/core.c b/kernel/futex/core.c > index 514e4582b863..f10587d1d481 100644 > --- a/kernel/futex/core.c > +++ b/kernel/futex/core.c > @@ -1132,8 +1132,7 @@ static int __init futex_init(void) > #endif > > futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues), > - futex_hashsize, 0, > - futex_hashsize < 256 ? HASH_SMALL : 0, > + futex_hashsize, 0, 0, > &futex_shift, NULL, > futex_hashsize, futex_hashsize); > futex_hashsize = 1UL << futex_shift; > diff --git a/mm/mm_init.c b/mm/mm_init.c > index d393631599a7..fab3c4649d5b 100644 > --- a/mm/mm_init.c > +++ b/mm/mm_init.c > @@ -2492,15 +2492,7 @@ void *__init alloc_large_system_hash(const char *tablename, > else > numentries <<= (PAGE_SHIFT - scale); > > - /* Make sure we've got at least a 0-order allocation.. */ > - if (unlikely(flags & HASH_SMALL)) { > - /* Makes no sense without HASH_EARLY */ > - WARN_ON(!(flags & HASH_EARLY)); > - if (!(numentries >> *_hash_shift)) { > - numentries = 1UL << *_hash_shift; > - BUG_ON(!numentries); > - } > - } else if (unlikely((numentries * bucketsize) < PAGE_SIZE)) > + if (unlikely((numentries * bucketsize) < PAGE_SIZE)) > numentries = PAGE_SIZE / bucketsize; > } > numentries = roundup_pow_of_two(numentries); > -- > 2.27.0 >
On 2023/6/17 15:56, Mike Rapoport wrote: > On Sat, Jun 17, 2023 at 03:09:55PM +0800, Miaohe Lin wrote: >> HASH_SMALL only works when parameter numentries is 0. But the sole caller >> futex_init() never calls alloc_large_system_hash() with numentries set to >> 0. > Thanks for your quick review. > Doesn't it? > What happens when CONFIG_BASE_SMALL is set? When CONFIG_BASE_SMALL is set, futex_hashsize is set to 16 and alloc_large_system_hash() is called with numentries == 16 && flags == HASH_SMALL. But in the alloc_large_system_hash(), we have the below logic: alloc_large_system_hash() { if (!numentries) { /* numentries == 16 here, so this code block is skipped. */ ... if (unlikely(flags & HASH_SMALL)) { /* So as here. */ ... } ... } So HASH_SMALL is just unused. Or am I miss something? Thanks. > >> So HASH_SMALL is obsolete and remove it. > >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> >> --- >> include/linux/memblock.h | 2 -- >> kernel/futex/core.c | 3 +-- >> mm/mm_init.c | 10 +--------- >> 3 files changed, 2 insertions(+), 13 deletions(-) >> >> diff --git a/include/linux/memblock.h b/include/linux/memblock.h >> index f71ff9f0ec81..346d80809517 100644 >> --- a/include/linux/memblock.h >> +++ b/include/linux/memblock.h >> @@ -581,8 +581,6 @@ extern void *alloc_large_system_hash(const char *tablename, >> unsigned long high_limit); >> >> #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ >> -#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min >> - * shift passed via *_hash_shift */ >> #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ >> >> /* Only NUMA needs hash distribution. 64bit NUMA architectures have >> diff --git a/kernel/futex/core.c b/kernel/futex/core.c >> index 514e4582b863..f10587d1d481 100644 >> --- a/kernel/futex/core.c >> +++ b/kernel/futex/core.c >> @@ -1132,8 +1132,7 @@ static int __init futex_init(void) >> #endif >> >> futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues), >> - futex_hashsize, 0, >> - futex_hashsize < 256 ? HASH_SMALL : 0, >> + futex_hashsize, 0, 0, >> &futex_shift, NULL, >> futex_hashsize, futex_hashsize); >> futex_hashsize = 1UL << futex_shift; >> diff --git a/mm/mm_init.c b/mm/mm_init.c >> index d393631599a7..fab3c4649d5b 100644 >> --- a/mm/mm_init.c >> +++ b/mm/mm_init.c >> @@ -2492,15 +2492,7 @@ void *__init alloc_large_system_hash(const char *tablename, >> else >> numentries <<= (PAGE_SHIFT - scale); >> >> - /* Make sure we've got at least a 0-order allocation.. */ >> - if (unlikely(flags & HASH_SMALL)) { >> - /* Makes no sense without HASH_EARLY */ >> - WARN_ON(!(flags & HASH_EARLY)); >> - if (!(numentries >> *_hash_shift)) { >> - numentries = 1UL << *_hash_shift; >> - BUG_ON(!numentries); >> - } >> - } else if (unlikely((numentries * bucketsize) < PAGE_SIZE)) >> + if (unlikely((numentries * bucketsize) < PAGE_SIZE)) >> numentries = PAGE_SIZE / bucketsize; >> } >> numentries = roundup_pow_of_two(numentries); >> -- >> 2.27.0 >> >
On Sat, Jun 17, 2023 at 04:39:44PM +0800, Miaohe Lin wrote: > On 2023/6/17 15:56, Mike Rapoport wrote: > > On Sat, Jun 17, 2023 at 03:09:55PM +0800, Miaohe Lin wrote: > >> HASH_SMALL only works when parameter numentries is 0. But the sole caller > >> futex_init() never calls alloc_large_system_hash() with numentries set to > >> 0. > > > > Thanks for your quick review. > > > Doesn't it? > > What happens when CONFIG_BASE_SMALL is set? > > When CONFIG_BASE_SMALL is set, futex_hashsize is set to 16 and alloc_large_system_hash() is called with > numentries == 16 && flags == HASH_SMALL. But in the alloc_large_system_hash(), we have the below logic: > > alloc_large_system_hash() > { > if (!numentries) { /* numentries == 16 here, so this code block is skipped. */ > ... > if (unlikely(flags & HASH_SMALL)) { /* So as here. */ > ... > } > ... > } > > So HASH_SMALL is just unused. Or am I miss something? You are right, I've missed that. > Thanks. > > > > >> So HASH_SMALL is obsolete and remove it. > > > >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> > >> --- > >> include/linux/memblock.h | 2 -- > >> kernel/futex/core.c | 3 +-- > >> mm/mm_init.c | 10 +--------- > >> 3 files changed, 2 insertions(+), 13 deletions(-) > >> > >> diff --git a/include/linux/memblock.h b/include/linux/memblock.h > >> index f71ff9f0ec81..346d80809517 100644 > >> --- a/include/linux/memblock.h > >> +++ b/include/linux/memblock.h > >> @@ -581,8 +581,6 @@ extern void *alloc_large_system_hash(const char *tablename, > >> unsigned long high_limit); > >> > >> #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ > >> -#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min > >> - * shift passed via *_hash_shift */ > >> #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ Can you update HASH_ZERO to 0x2? > >> > >> /* Only NUMA needs hash distribution. 64bit NUMA architectures have > >> diff --git a/kernel/futex/core.c b/kernel/futex/core.c > >> index 514e4582b863..f10587d1d481 100644 > >> --- a/kernel/futex/core.c > >> +++ b/kernel/futex/core.c > >> @@ -1132,8 +1132,7 @@ static int __init futex_init(void) > >> #endif > >> > >> futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues), > >> - futex_hashsize, 0, > >> - futex_hashsize < 256 ? HASH_SMALL : 0, > >> + futex_hashsize, 0, 0, > >> &futex_shift, NULL, > >> futex_hashsize, futex_hashsize); > >> futex_hashsize = 1UL << futex_shift; > >> diff --git a/mm/mm_init.c b/mm/mm_init.c > >> index d393631599a7..fab3c4649d5b 100644 > >> --- a/mm/mm_init.c > >> +++ b/mm/mm_init.c > >> @@ -2492,15 +2492,7 @@ void *__init alloc_large_system_hash(const char *tablename, > >> else > >> numentries <<= (PAGE_SHIFT - scale); > >> > >> - /* Make sure we've got at least a 0-order allocation.. */ > >> - if (unlikely(flags & HASH_SMALL)) { > >> - /* Makes no sense without HASH_EARLY */ > >> - WARN_ON(!(flags & HASH_EARLY)); > >> - if (!(numentries >> *_hash_shift)) { > >> - numentries = 1UL << *_hash_shift; > >> - BUG_ON(!numentries); > >> - } > >> - } else if (unlikely((numentries * bucketsize) < PAGE_SIZE)) > >> + if (unlikely((numentries * bucketsize) < PAGE_SIZE)) > >> numentries = PAGE_SIZE / bucketsize; > >> } > >> numentries = roundup_pow_of_two(numentries); > >> -- > >> 2.27.0 > >> > > >
On 2023/6/17 18:51, Mike Rapoport wrote: > On Sat, Jun 17, 2023 at 04:39:44PM +0800, Miaohe Lin wrote: >> On 2023/6/17 15:56, Mike Rapoport wrote: >>> On Sat, Jun 17, 2023 at 03:09:55PM +0800, Miaohe Lin wrote: >>>> HASH_SMALL only works when parameter numentries is 0. But the sole caller >>>> futex_init() never calls alloc_large_system_hash() with numentries set to >>>> 0. >>> >> >> Thanks for your quick review. >> >>> Doesn't it? >>> What happens when CONFIG_BASE_SMALL is set? >> >> When CONFIG_BASE_SMALL is set, futex_hashsize is set to 16 and alloc_large_system_hash() is called with >> numentries == 16 && flags == HASH_SMALL. But in the alloc_large_system_hash(), we have the below logic: >> >> alloc_large_system_hash() >> { >> if (!numentries) { /* numentries == 16 here, so this code block is skipped. */ >> ... >> if (unlikely(flags & HASH_SMALL)) { /* So as here. */ >> ... >> } >> ... >> } >> >> So HASH_SMALL is just unused. Or am I miss something? > > You are right, I've missed that. > >> Thanks. >> >>> >>>> So HASH_SMALL is obsolete and remove it. >>> >>>> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> >>>> --- >>>> include/linux/memblock.h | 2 -- >>>> kernel/futex/core.c | 3 +-- >>>> mm/mm_init.c | 10 +--------- >>>> 3 files changed, 2 insertions(+), 13 deletions(-) >>>> >>>> diff --git a/include/linux/memblock.h b/include/linux/memblock.h >>>> index f71ff9f0ec81..346d80809517 100644 >>>> --- a/include/linux/memblock.h >>>> +++ b/include/linux/memblock.h >>>> @@ -581,8 +581,6 @@ extern void *alloc_large_system_hash(const char *tablename, >>>> unsigned long high_limit); >>>> >>>> #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ >>>> -#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min >>>> - * shift passed via *_hash_shift */ >>>> #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ > > Can you update HASH_ZERO to 0x2? Will do. Thanks.
diff --git a/include/linux/memblock.h b/include/linux/memblock.h index f71ff9f0ec81..346d80809517 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -581,8 +581,6 @@ extern void *alloc_large_system_hash(const char *tablename, unsigned long high_limit); #define HASH_EARLY 0x00000001 /* Allocating during early boot? */ -#define HASH_SMALL 0x00000002 /* sub-page allocation allowed, min - * shift passed via *_hash_shift */ #define HASH_ZERO 0x00000004 /* Zero allocated hash table */ /* Only NUMA needs hash distribution. 64bit NUMA architectures have diff --git a/kernel/futex/core.c b/kernel/futex/core.c index 514e4582b863..f10587d1d481 100644 --- a/kernel/futex/core.c +++ b/kernel/futex/core.c @@ -1132,8 +1132,7 @@ static int __init futex_init(void) #endif futex_queues = alloc_large_system_hash("futex", sizeof(*futex_queues), - futex_hashsize, 0, - futex_hashsize < 256 ? HASH_SMALL : 0, + futex_hashsize, 0, 0, &futex_shift, NULL, futex_hashsize, futex_hashsize); futex_hashsize = 1UL << futex_shift; diff --git a/mm/mm_init.c b/mm/mm_init.c index d393631599a7..fab3c4649d5b 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2492,15 +2492,7 @@ void *__init alloc_large_system_hash(const char *tablename, else numentries <<= (PAGE_SHIFT - scale); - /* Make sure we've got at least a 0-order allocation.. */ - if (unlikely(flags & HASH_SMALL)) { - /* Makes no sense without HASH_EARLY */ - WARN_ON(!(flags & HASH_EARLY)); - if (!(numentries >> *_hash_shift)) { - numentries = 1UL << *_hash_shift; - BUG_ON(!numentries); - } - } else if (unlikely((numentries * bucketsize) < PAGE_SIZE)) + if (unlikely((numentries * bucketsize) < PAGE_SIZE)) numentries = PAGE_SIZE / bucketsize; } numentries = roundup_pow_of_two(numentries);