From patchwork Mon May 22 11:20:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "T.J. Alumbaugh" X-Patchwork-Id: 13250198 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 86956C7EE2A for ; Mon, 22 May 2023 11:21:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04894280003; Mon, 22 May 2023 07:21:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F17DC280001; Mon, 22 May 2023 07:21:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8D1D280003; Mon, 22 May 2023 07:21:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C663D280001 for ; Mon, 22 May 2023 07:21:18 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A67F780515 for ; Mon, 22 May 2023 11:21:18 +0000 (UTC) X-FDA: 80817649836.25.E908077 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf07.hostedemail.com (Postfix) with ESMTP id 847C640017 for ; Mon, 22 May 2023 11:21:16 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=6rDOmfXO; spf=pass (imf07.hostedemail.com: domain of 3K1BrZAgKCKIVCNWODCWIQQING.EQONKPWZ-OOMXCEM.QTI@flex--talumbau.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3K1BrZAgKCKIVCNWODCWIQQING.EQONKPWZ-OOMXCEM.QTI@flex--talumbau.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684754476; 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=cIw0V38F7EAw1HDE4zn4HtkfS4SFwenBLbiqkZiF2tk=; b=ByqVTDkX+JYnlQH3pFB6rjmO6EpOYrVSaHE2Yh03ma/PLpqEvmFFhlOGUlfYQrbM3iK54j HWEmwY5Zks8G4v8V7tZUDzXsIMy/g9fGL/GlhucZaN5s+e4WwkC2Zwbqji3CEspJv6OVIK vUxk6YsA4sUPHqwGhI1hM+WS4T2fk40= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684754476; a=rsa-sha256; cv=none; b=cI4HGT5T6scJw83V7gc7Fqbd4DFUqetunooPe/20BCLBncxwabN1lLOJb8oKPtN61u9bj4 EEkBgH+KHnJLf7ii/7Wr9SlX2ty2KADd3gaqZxn0QOaUkLpvVign+I5TPL233wEEFozYhm IWNkUPglSFvRWM9IveOyi+yIr8ln0/s= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=6rDOmfXO; spf=pass (imf07.hostedemail.com: domain of 3K1BrZAgKCKIVCNWODCWIQQING.EQONKPWZ-OOMXCEM.QTI@flex--talumbau.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3K1BrZAgKCKIVCNWODCWIQQING.EQONKPWZ-OOMXCEM.QTI@flex--talumbau.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-564eb7bc5a2so25589747b3.2 for ; Mon, 22 May 2023 04:21:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1684754475; x=1687346475; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=cIw0V38F7EAw1HDE4zn4HtkfS4SFwenBLbiqkZiF2tk=; b=6rDOmfXOGOL1GW8BHq1lsmAkzsCgxjIn29uj6ZLID+SRaLqHrhM5DOXLA1DCB4iRhy a6Sk9ssRLW1lIRe1a08AwxJ0BAccFa/CgrcwVovKZQUfGQmd6jJ0qQPWDFU52nTje6Ve 1q24H2eJS6v/mPNZCYJE19c+FSpEKqVmHIn36QwkuInYq6A35uygUpQ6n7qaQFOqi+vd GFbbq8j/7Gls9AgbMdbyd1j1SVhiG2e54nQdxqL740BwFA6P/sWV6/odg2s/pJ3Q699D 5fHgG36i7bIXayaCDGk3RAO3su0zKcjC2JqYEecZCpk/VU295hRYwRTPKyfriu/y5jff zXAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684754475; x=1687346475; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cIw0V38F7EAw1HDE4zn4HtkfS4SFwenBLbiqkZiF2tk=; b=Yllp83p+JrB5/Zd6slIye1+DabLMyxCflP5b9iEoJSGfn+AaEg1YGpZr9VtmnO7Rjh CnhazcM3vYrCMibbdAmGXZOkQaLAfoRNDpLugt0KwAfh1ksscG7ZrwNB3B+a/jM81sCf zCkcq9a0gou4+xTG5cn48tD4nVFB63njuIj/cXcH+JpJE1ddR0UQIdjR3qt/RhUek1Nv YAXD5uitbE45cZN+KgOThkE1fEy/ziAv7wGWes+oqJzH2JBJt5+V1hNnvtulM0v5mHdP l82koEf2ZolunEjzYH4b7QdGqrmvCKSE5OSdwPl7i4NlAq6EeAuQfQ5PFxukQuxGgnBg b2Iw== X-Gm-Message-State: AC+VfDzbmqP8Jn10D6xMPcwrsN4651GJkSUcdOKp3Ry0vWpwzbdEn/ST JjI2yRKWaW35sF5KDpn1yTItqfZiuYaQSQ== X-Google-Smtp-Source: ACHHUZ4DoNgWjW81d3zb12J4YKX9fJCnoBsTiCFKxDr8tt1dmILx5fK2udZ/QgC3AM2KeSxtmeQ5pfTpZG18cA== X-Received: from talumbau.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:90d]) (user=talumbau job=sendgmr) by 2002:a81:dc01:0:b0:561:c98b:8e8e with SMTP id h1-20020a81dc01000000b00561c98b8e8emr6749837ywj.10.1684754475539; Mon, 22 May 2023 04:21:15 -0700 (PDT) Date: Mon, 22 May 2023 11:20:58 +0000 In-Reply-To: <20230522112058.2965866-1-talumbau@google.com> Mime-Version: 1.0 References: <20230522112058.2965866-1-talumbau@google.com> Message-ID: <20230522112058.2965866-4-talumbau@google.com> Subject: [PATCH mm-unstable 4/4] mm: multi-gen LRU: cleanup lru_gen_test_recent() From: "T.J. Alumbaugh" To: Andrew Morton Cc: Yuanchu Xie , Yu Zhao , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mm@google.com, "T.J. Alumbaugh" X-Rspamd-Queue-Id: 847C640017 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jwhwxafzxcuhx8h3gb5cmg9gd74sxxtx X-HE-Tag: 1684754476-297380 X-HE-Meta: U2FsdGVkX1/h65eCgHxXBcj8vc5mMgrhmmZyyn+gGQvaFTAV8bIw14E0lekzz+WfgxmJOiI9/xtA2s+6mS22WlfXf5HIsEJSg+nbZBeB5Qjcor312dkD0dEVcYn3MjprjGkCRn5cE5Q6+h7xkRb20GVfKTW+I/cSzWb0cZkgLWHfhNoVcZMtMIp4rKRAebS2Npj0lqB035c4S4CIBQ9pSnQ9URSzNmTcyD1pZWyBltgKR5tLUrM09zL7GqacMQZRWE6PdxSPDzb6ANt/u9e+Gn2mIlB0eFeWDsQE7Cgbe8hMT75iIRTbc4IRs/JBGa0qozr02cVHyu6XizrjUkQ94XJSj3YWZ5OYETS8PbFBqYGd9AMbHJIQ8CWp3wh6QSqTCfzhGwNYaI99ZB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S3kEMSACSgx4VDx1rimgnZnc8Jap91l8A5PhJ/QyuZIPagcSlcoYXWdTpWf+GUHbKwBD3lyJHssa2su0207wRMAkJkqEEsfdvfyRP+R5wZg6pXJRieoP7t1JJ/BXJOhUzpJTuHlBfKjffuTaaOFmd1wq8LMHbkIdA8Jx7hmsih+nW3ZKsQR0Gh6H X-Bogosity: Ham, tests=bogofilter, spamicity=0.012039, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Avoid passing memcg* and pglist_data* to lru_gen_test_recent() since we only use the lruvec anyway. Signed-off-by: T.J. Alumbaugh --- mm/workingset.c | 46 ++++++++++++++++------------------------------ 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/mm/workingset.c b/mm/workingset.c index 90ae785d4c9c..5796e927e6d7 100644 --- a/mm/workingset.c +++ b/mm/workingset.c @@ -257,59 +257,46 @@ static void *lru_gen_eviction(struct folio *folio) /* * Tests if the shadow entry is for a folio that was recently evicted. - * Fills in @memcgid, @pglist_data, @token, @workingset with the values - * unpacked from shadow. + * Fills in @lruvec, @token, @workingset with the values unpacked from shadow. */ -static bool lru_gen_test_recent(void *shadow, bool file, int *memcgid, - struct pglist_data **pgdat, unsigned long *token, bool *workingset) +static bool lru_gen_test_recent(void *shadow, bool file, struct lruvec **lruvec, + unsigned long *token, bool *workingset) { - struct mem_cgroup *eviction_memcg; - struct lruvec *lruvec; - struct lru_gen_folio *lrugen; + int memcg_id; unsigned long min_seq; + struct mem_cgroup *memcg; + struct pglist_data *pgdat; - unpack_shadow(shadow, memcgid, pgdat, token, workingset); - eviction_memcg = mem_cgroup_from_id(*memcgid); + unpack_shadow(shadow, &memcg_id, &pgdat, token, workingset); - lruvec = mem_cgroup_lruvec(eviction_memcg, *pgdat); - lrugen = &lruvec->lrugen; + memcg = mem_cgroup_from_id(memcg_id); + *lruvec = mem_cgroup_lruvec(memcg, pgdat); - min_seq = READ_ONCE(lrugen->min_seq[file]); + min_seq = READ_ONCE((*lruvec)->lrugen.min_seq[file]); return (*token >> LRU_REFS_WIDTH) == (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH)); } static void lru_gen_refault(struct folio *folio, void *shadow) { int hist, tier, refs; - int memcg_id; bool workingset; unsigned long token; - unsigned long min_seq; struct lruvec *lruvec; struct lru_gen_folio *lrugen; - struct mem_cgroup *memcg; - struct pglist_data *pgdat; int type = folio_is_file_lru(folio); int delta = folio_nr_pages(folio); rcu_read_lock(); - if (!lru_gen_test_recent(shadow, type, &memcg_id, &pgdat, &token, - &workingset)) + if (!lru_gen_test_recent(shadow, type, &lruvec, &token, &workingset)) goto unlock; - memcg = folio_memcg_rcu(folio); - if (memcg_id != mem_cgroup_id(memcg)) + if (lruvec != folio_lruvec(folio)) goto unlock; - if (pgdat != folio_pgdat(folio)) - goto unlock; - - lruvec = mem_cgroup_lruvec(memcg, pgdat); lrugen = &lruvec->lrugen; - min_seq = READ_ONCE(lrugen->min_seq[type]); - hist = lru_hist_from_seq(min_seq); + hist = lru_hist_from_seq(READ_ONCE(lrugen->min_seq[type])); /* see the comment in folio_lru_refs() */ refs = (token & (BIT(LRU_REFS_WIDTH) - 1)) + workingset; tier = lru_tier_from_refs(refs); @@ -339,8 +326,8 @@ static void *lru_gen_eviction(struct folio *folio) return NULL; } -static bool lru_gen_test_recent(void *shadow, bool file, int *memcgid, - struct pglist_data **pgdat, unsigned long *token, bool *workingset) +static bool lru_gen_test_recent(void *shadow, bool file, struct lruvec **lruvec, + unsigned long *token, bool *workingset) { return false; } @@ -435,8 +422,7 @@ bool workingset_test_recent(void *shadow, bool file, bool *workingset) unsigned long eviction; if (lru_gen_enabled()) - return lru_gen_test_recent(shadow, file, &memcgid, &pgdat, &eviction, - workingset); + return lru_gen_test_recent(shadow, file, &eviction_lruvec, &eviction, workingset); unpack_shadow(shadow, &memcgid, &pgdat, &eviction, workingset); eviction <<= bucket_order;