Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1809140rdb; Wed, 20 Sep 2023 23:12:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTd5fTZeckyL3qV7sP28ACMiWY+ZzRAM7FWxMd6lZ20C13B82iF25bZWjHayn7Cq+FRY0c X-Received: by 2002:a05:6358:7213:b0:141:162:b0cd with SMTP id h19-20020a056358721300b001410162b0cdmr6284925rwa.19.1695276756458; Wed, 20 Sep 2023 23:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695276756; cv=none; d=google.com; s=arc-20160816; b=hxAyHmjGlqXbWJhXiaDMO1VLQ6IWQ9v+xukFCK7W81uBCNK1JS5vYxowfc8jnHQIYC 1GWbw4PD2hDNy+7C97jps/5ny25tUomo8IHnTISYQ22AXcuPuUeZTzpBYx1W5qGp14QB eBSKGqDxhjckCBGQIJSyTLkQUl6WDp8s0WnAAxn+7vQmvVN55gBdpy1cAwDrM7KYBc64 s0GcfJNIFcMeUwRc9uN248ScM8biS3H3HVW+W0WHYr3Fco2ByOHUKbh1JgbE1TxJVjE4 Bcb+KfZq81fSTAcJErm/ggTEkMoO1Ew9vcmAUqaeH2uLyrsBnWy14Ge/2XVebDMev4Kh fAkQ== 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:reply-to :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=fTb+Ik2udqF6O5creFYnCkxLACYh4nJ1pznoCTKYdgg=; fh=E4Dx6FsRR0bUU1V9Gy1LgJPpghBs+NaR6FSgB1AfVlI=; b=ygDm+C4YQpcOjxWIE3exmoSjogSYrrAZulP6UJ+TSR55ENYGTTMycECd+xQ1eaya0X mpeRPtF11IRY/WIJ29nFYo28aOnADfXwD4AreX8HiSflKXgTZX1vR4c+WttV60lYaiDx Z1B2bx8cr9b4dUEGj3ahu1SGGDzNC0KbPKpjQTzD18bDiBKjYUTjksdprzlA0qPWNz/5 WX3e6pHQTYCGxBjGxwPEcCCObiJzx8Y4lbEnVXUdPYZhmbVaxjVpQGFjV+cg6UAr4R39 EcCKttxauWihwrrnTzm8b/6XW0vOUKqL+PmjGM9yD9TLI3Cf5Dcc5AgM97Z/rx4zbh/j fz+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cOZzq3xE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x3-20020a636303000000b0055fdd303745si713210pgb.421.2023.09.20.23.12.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 23:12:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=cOZzq3xE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 80BD2807FCDA; Wed, 20 Sep 2023 12:03:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbjITTDZ (ORCPT + 99 others); Wed, 20 Sep 2023 15:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbjITTDV (ORCPT ); Wed, 20 Sep 2023 15:03:21 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B80C2 for ; Wed, 20 Sep 2023 12:03:12 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-690fe10b6a4so102262b3a.3 for ; Wed, 20 Sep 2023 12:03:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695236592; x=1695841392; darn=vger.kernel.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=cOZzq3xEY/EzAjSu/J2gB67UYARR/97qXxfEnak7ificFrznnSQT5c8KElVc/KhbHP kwZ8PBDdTfpRxbpFwjz2BEH5z4/F9ZQ+zJVuLYWgCjC5pmkvmBVQrO7LOfK+ORaVwYh6 3w7b8Lq5CAPTVmCTH3mElMs6fzTuJT9q0ktDn7thXTGz/My1nMHSP9WenfbF2ce10AKS erIaO0pedz9d3H+tX1z2xArUu/Bknns3Yf9FWPNe+RSXfSgKoS+2z2W31RCi7N3OKrfw QnGLXSMinBN5SPtm2AO0k+zJM+dpP4KQG5r/XSOTnI4PWEa3Rl2p6PAzoFVr/S0guklM nnsw== 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=jdZyv6o7q8QPERSua6mk8/bBHxXpbbreQnqupa23+9k+/G06slC3gpCNNE5GDuaSFR xMoV/wT6WtSdNheBMaaAWTObCTSvJU+Cbme3tUagD94gwhin/7Fq2kmvg0g/1bIJCk03 sEvIEScC6q1KmiBHpckxu9gDQcGnAWSrZnmFM++rk3TdcbBj8BZnXU73BGjynL+7QHER H0NZVK8cxSqxPLy/MnDk3Nm1gmMYb5giskY58ZcP8GqcIfpY6AkcUGxU1Kwl5t9qEn62 kETS3EDdKBQXKaVcqNczq83+P+Zs9TdS4U3gBq8RoZWiAFIUNpl6/7LJM7CMyXsV85ZQ vQ3g== X-Gm-Message-State: AOJu0YxNJhoKabfEYsJqPOkNhjeJ23Jm/nHGNUUMmVyFeAQDZRWn9wmK CKdsPjm83gMj1J8xWTPYoK8= 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 20 Sep 2023 12:03:42 -0700 (PDT) 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) -- 2.41.0