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 X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5E8C6C433E0 for ; Mon, 1 Feb 2021 13:02:16 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E39D264DDB for ; Mon, 1 Feb 2021 13:02:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E39D264DDB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4E10E6B0070; Mon, 1 Feb 2021 08:02:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 491A96B0071; Mon, 1 Feb 2021 08:02:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3D01D6B0073; Mon, 1 Feb 2021 08:02:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 285566B0070 for ; Mon, 1 Feb 2021 08:02:15 -0500 (EST) Received: from smtpin26.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id DBCE5824999B for ; Mon, 1 Feb 2021 13:02:14 +0000 (UTC) X-FDA: 77769712188.26.egg62_1803312275c2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin26.hostedemail.com (Postfix) with ESMTP id BBD331804B65A for ; Mon, 1 Feb 2021 13:02:14 +0000 (UTC) X-HE-Tag: egg62_1803312275c2 X-Filterd-Recvd-Size: 3082 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf28.hostedemail.com (Postfix) with ESMTP for ; Mon, 1 Feb 2021 13:02:14 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E188EAC45; Mon, 1 Feb 2021 13:02:12 +0000 (UTC) Subject: Re: [PATCH] mm: workingset: clarify eviction order and distance calculation To: Oscar Salvador , akpm@linux-foundation.org Cc: hannes@cmpxchg.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20210201060651.3781-1-osalvador@suse.de> From: Vlastimil Babka Message-ID: <90fd6f25-cefe-34ab-de33-616e8d4dd6f0@suse.cz> Date: Mon, 1 Feb 2021 14:02:12 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: <20210201060651.3781-1-osalvador@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2/1/21 7:06 AM, Oscar Salvador wrote: > The premise of the refault distance is that it can be seen as a deficit > of the inactive list space, so that if the inactive list would have had > (R - E) more slots, the page would not have been evicted but promoted > to the active list instead. > > However, the way the code is ordered right now set us to be off by one, > so the real number of slots would be (R - E) + 1. > I stumbled upon this when trying to understand the code and it puzzled me > that the comments did not match what the code did. > > This it not an issue at all since evictions and refaults tend to happen > in a number large enough that being off-by-one does not have any impact > - and since the compiler and CPUs are free to rearrange the execution > sequence anyway. > But as Johannes says, it is better to re-arrange the code in the proper > order since otherwise would be misleading to somebody who is actively > reading and trying to understand the logic of the code - like it > happened to me. > > Signed-off-by: Oscar Salvador > Acked-by: Johannes Weiner Acked-by: Vlastimil Babka > --- > mm/workingset.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/workingset.c b/mm/workingset.c > index 10e96de945b3..0201aa1ff320 100644 > --- a/mm/workingset.c > +++ b/mm/workingset.c > @@ -263,10 +263,10 @@ void *workingset_eviction(struct page *page, struct mem_cgroup *target_memcg) > VM_BUG_ON_PAGE(!PageLocked(page), page); > > lruvec = mem_cgroup_lruvec(target_memcg, pgdat); > - workingset_age_nonresident(lruvec, thp_nr_pages(page)); > /* XXX: target_memcg can be NULL, go through lruvec */ > memcgid = mem_cgroup_id(lruvec_memcg(lruvec)); > eviction = atomic_long_read(&lruvec->nonresident_age); > + workingset_age_nonresident(lruvec, thp_nr_pages(page)); > return pack_shadow(memcgid, pgdat, eviction, PageWorkingset(page)); > } > >