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 B2215EB64D9 for ; Sat, 17 Jun 2023 10:52:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E0326B0072; Sat, 17 Jun 2023 06:52:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08FC68E0001; Sat, 17 Jun 2023 06:52:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC0096B0078; Sat, 17 Jun 2023 06:52:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id DD1116B0072 for ; Sat, 17 Jun 2023 06:52:20 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 98B98160D1C for ; Sat, 17 Jun 2023 10:52:20 +0000 (UTC) X-FDA: 80911925640.05.5C3CF8E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id EB37712000A for ; Sat, 17 Jun 2023 10:52:17 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T7B4It7y; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1686999138; 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=1HT8QGH5kMCihBzerq0TFoY4X6i17UuHZIijsIlzuzQ=; b=g8k6pKLt4+48b6JzYKE8SGE3qj4Cm9WLu3IPybG5vX1XTNZNwQ69Vj5Qc0I2Plp9z9cPdy OSkYVR9Qciu6ZTM7N9vpj1mrrQ29kkazHmvE72ChM2B2wp0hlX5yv9UMTw7tQQv/pt0Mcy MTTgy/WLLPjDZxKF8mrjLf1ulvi2aaY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686999138; a=rsa-sha256; cv=none; b=YnzZt98IQyht4thIMP4/sAhlOOAZVkb23erTy8IdQHIa+43fd8GyJ31Og57wPRexmu5C0Z V5ysnGMsYZbTO2MymSDERSi3JsasC4xtZCmzW/sXwh7Fo3TFiAJRgVDEhgxqu7QjWYAobg jCCLA3VoEYAKZwY08dg89hIWTBwia9I= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=T7B4It7y; spf=pass (imf29.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DFE8A6069A; Sat, 17 Jun 2023 10:52:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D959DC433C0; Sat, 17 Jun 2023 10:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686999136; bh=WiB5tt+dGicCP1dSR4iRdltEOzqRT8XN4J7t5k3g/Zo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=T7B4It7yaepq/T7zRX2xmX4h1hL1m/4+tS9nUaeaAxGMk+hqyYvsRMT7i9q4J6MuK ZayyYI+B7VqTIGQXVqqryhxtSaqOCDDnVJbYMFLXGJt7DWjS3Y4rk3FftC8f2S2W/Z R2oN0QwNFBYyoqIcovohJbG4OykTcgk820egxAPElplcBT58jcRBercnS5tvi6cDp4 hUIlyDW66VVCGydIB2U78f9u88mRK7K+UiAVbbxe8zPHF8aoFy8zvgSRlYFE5roxjQ Hafko6JXt6PuJTeK5reH7UdAE78Du348x/nD6q3SqdJiQRnaiBeb5m+6xmjhLGoK6y C/4swd4WLnMqQ== Date: Sat, 17 Jun 2023 13:51:37 +0300 From: Mike Rapoport To: Miaohe Lin Cc: akpm@linux-foundation.org, tglx@linutronix.de, mingo@redhat.com, peterz@infradead.org, dvhart@infradead.org, dave@stgolabs.net, andrealmeid@igalia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/mm_init.c: remove obsolete macro HASH_SMALL Message-ID: <20230617105137.GX52412@kernel.org> References: <20230617070955.1751393-1-linmiaohe@huawei.com> <20230617075644.GV52412@kernel.org> <6d149902-a944-7961-89c1-f07047953c7f@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d149902-a944-7961-89c1-f07047953c7f@huawei.com> X-Rspamd-Queue-Id: EB37712000A X-Rspam-User: X-Stat-Signature: kub8ecurcwipcmxihqhrthch3bhchtj7 X-Rspamd-Server: rspam03 X-HE-Tag: 1686999137-913047 X-HE-Meta: U2FsdGVkX18lWA+O7HkQU8H0X5hH4Axt44LbHr/LoGYqc5++NCQeVgQw3an44BKAN6RIBObIg1zqi27C2avt6wUMSxUBlssg0rPKZBbIRJPUIogpR/NknLAUS8UuuvmMNFdCUEPlY/yiKqnnBb3FW2yCIV4NlAJv8WQLzSopzx1SxjPBwjXLxs5e0Inf7FT+fjsrLrSX0OCgvqPoDDJ9mjulQ/k4mqREBaa1qumJkwIZOcKhsbgiGlqfdQ3SYF5/dd68jZ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yFS2c= 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 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 > >> --- > >> 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 > >> > > > -- Sincerely yours, Mike.