From patchwork Wed Sep 20 19:02:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13393225 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 787DFC04FEB for ; Wed, 20 Sep 2023 19:03:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0DF496B0194; Wed, 20 Sep 2023 15:03:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 08F836B019C; Wed, 20 Sep 2023 15:03:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E98626B019D; Wed, 20 Sep 2023 15:03:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D8EC86B0194 for ; Wed, 20 Sep 2023 15:03:15 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B0DD9120CAC for ; Wed, 20 Sep 2023 19:03:15 +0000 (UTC) X-FDA: 81257898750.05.742BA83 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by imf14.hostedemail.com (Postfix) with ESMTP id A7B8F100034 for ; Wed, 20 Sep 2023 19:03:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aQlYuhu0; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695236593; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fTb+Ik2udqF6O5creFYnCkxLACYh4nJ1pznoCTKYdgg=; b=QcYte2tlXSaps2mpF9usf50CYaDa+isEYZR27Mekk/tmzVYIpZsg4q/p4izSZlv4HNuddB TOYLDatiwlUXuOE2RUsBKU3g9vx8LIXfJAmZO394SBoNBH4mlV66KKjycebFXZPwLcbFW4 hVEwpjXN0/2qZ0DWs/V9P2k+cEJ5omQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695236593; a=rsa-sha256; cv=none; b=At4VlyOnto9eajf4e9FxOs+5hD4moGrqOpNxrXBNkwXNCWu+WmfKyhoAnYF3+ttWu0hcDI lTz8J7PiGRZGPB42NKHbtAIzbx1BAq3mpls02ymRCAzc9gfyR4RtJtfG5Ka2TxUnk0LWwg GnichaTfAPHmuvILfNBVVAq7ynkm2es= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=aQlYuhu0; spf=pass (imf14.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.210.171 as permitted sender) smtp.mailfrom=ryncsn@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-68fe2470d81so111722b3a.1 for ; Wed, 20 Sep 2023 12:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695236592; x=1695841392; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=fTb+Ik2udqF6O5creFYnCkxLACYh4nJ1pznoCTKYdgg=; b=aQlYuhu0kmLqDEl4U/qnuaQZmsYuNVJ8dU/xStsjbDNJUfEHh0FZoG2GeOV09gYJmQ 1j0CbxvUwoqiHY0i7oZ02jZ/vb4HmqNt5TN8RdETG7jlK7pEmOz8dwdMpk1AF2QQFilS 8QVUoDc6BfTuAY2acyez6/Dp9/TUAbCRt2XiIGq0SEBGLaA/1Plfbsi7oX20JCw+yZgc uM6j78XgmX76Mp6adeZtA+SFYL9kOyaPkHJ/ZrYYCa53rCObJF/rzUZ1qzhkyA6pWI/G 1JURs28ZJ12RK1CXwt9SC4vyz0dkE5lb7atrUSjSvU5csdqzEU5dvRea8Tzej/1D50v8 66BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695236592; x=1695841392; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=fTb+Ik2udqF6O5creFYnCkxLACYh4nJ1pznoCTKYdgg=; b=kOE3jiEOa/dlydMJrNlVOVa6jMiOb4vBNbLc7zHBTpr3hkZh/MhVRvop3LzAKJk8yC qW1Cq6SWpzNdrIrDG02VowsPP4jeZbNjclpXbf8zs4lrrlWM0VnxeUYvAilj2SVnRrLw Kq9+m4UqJWdJY48C3HIuGgTj21TsJYZ/n7OgFEH0oPlY/ykeKWYLniu2VLI5omLuYuTb T5NaE1Y2ugr2zs4/6SsMbtEKdsDfPo9bAhtyNKxSu1fhN3er1chFVnywGTcHowSi1FGB /KxU7Ai1DbSBfjAN/QY9EAs4M95U89IqKJ+jSPLJv541vKaXSIkn9g80tpZZpc6FCQpL PSxQ== X-Gm-Message-State: AOJu0YwubPZq0tvux5gXYiIIbfx2Bsqo7JlnSbGdtKOpSNnKCDR9nMV2 aDd6sBta50IsyfnKWSWX4TZVeTMg1vktEWRS X-Google-Smtp-Source: AGHT+IGOR3t7SCi0X1jSkUkFA5SJ42qQ186NGsFE41qOKCO7kuJQXQAUD43UH6S65kiieutgbFyoyA== X-Received: by 2002:a05:6a20:3ca7:b0:13a:59b1:c884 with SMTP id b39-20020a056a203ca700b0013a59b1c884mr3984546pzj.40.1695236591863; Wed, 20 Sep 2023 12:03:11 -0700 (PDT) Received: from KASONG-MB2.tencent.com ([124.127.145.18]) by smtp.gmail.com with ESMTPSA id m5-20020aa78a05000000b006871fdde2c7sm423935pfa.110.2023.09.20.12.03.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 20 Sep 2023 12:03:11 -0700 (PDT) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Yu Zhao , Roman Gushchin , Johannes Weiner , Michal Hocko , Hugh Dickins , Nhat Pham , Yuanchu Xie , Kalesh Singh , Suren Baghdasaryan , "T . J . Mercier" , linux-kernel@vger.kernel.org, Kairui Song Subject: [RFC PATCH v3 3/6] workignset: simplify the initilization code Date: Thu, 21 Sep 2023 03:02:41 +0800 Message-ID: <20230920190244.16839-4-ryncsn@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230920190244.16839-1-ryncsn@gmail.com> References: <20230920190244.16839-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: A7B8F100034 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 74aogwtzhd418b95rhue73grwzozao57 X-HE-Tag: 1695236593-710060 X-HE-Meta: U2FsdGVkX19KUsZlWfc6VxW/MhQYOnd/BOAp2IxuoIbctLm0GmlK2Vq0LNQgSamdK7CsLhNFnxxpMZueEI84VI+BsoNS0ZAbQ8IJ2bGwGaZmi8sbszy6Vn4e0J65o2PjWETuMxJpswiZqgPvtNa7q9SvZmfvLue+zqoHXBbsfXFKgASZaLU+01+yBy0gVfWIY/7+bQ0aVarzuqcRg6lsgcoD/kjkncOD1yjnkM79IHxWPxVwXekY1Ytq/WMWq1MLWzCutjg9L/c/qQmPJVTzlNkRcZ64UYeKBDKSsmGcmBZiphzZeCCPtDunhzUftvpuYzdy8MTmiv4Kr6YF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qF+mQKW+VVa0M2oeBPXXfhlgwugQfIhBsDS8ROCszM0gOmRmkDy7X1pM+kW78mKxbqCaQo8O5wWk3nMAKAYw+/0XngYj3Q2W1Vf6Xl2/ctcVZ0+1kQ9hnIcz+Xi+AzMWp6IstP/o70rPi7efjq/02pDI12tp8SmIQ3taVpVmpTCHhK0W1dx/G9tmGVPITS1NCTT26nRpmJ0yhU591 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Kairui Song Use the new introduced EVICTION_BITS to replace timestamp_bits, compiler should be able to optimize out the previous variable but this should make the code more clear and unified. Signed-off-by: Kairui Song --- mm/workingset.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index b0704cbfc667..278c3b9eb549 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -772,7 +772,6 @@ static struct lock_class_key shadow_nodes_key; static int __init workingset_init(void) { - unsigned int timestamp_bits; unsigned int max_order; int ret; @@ -784,12 +783,11 @@ static int __init workingset_init(void) * some more pages at runtime, so keep working with up to * double the initial memory by using totalram_pages as-is. */ - timestamp_bits = BITS_PER_LONG - EVICTION_SHIFT; max_order = fls_long(totalram_pages() - 1); - if (max_order > timestamp_bits) - bucket_order = max_order - timestamp_bits; + if (max_order > EVICTION_BITS) + bucket_order = max_order - EVICTION_BITS; pr_info("workingset: timestamp_bits=%d max_order=%d bucket_order=%u\n", - timestamp_bits, max_order, bucket_order); + EVICTION_BITS, max_order, bucket_order); ret = prealloc_shrinker(&workingset_shadow_shrinker, "mm-shadow"); if (ret)