Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2921222rwb; Fri, 20 Jan 2023 08:57:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnvimZhluOqYrjyV2Tzgzam7AP61n6ubO5Sw0MNaY21QAJHKhAzg/8RgBC9N6Ehy4GEeXx X-Received: by 2002:a05:6a20:1450:b0:b5:e1f5:c72f with SMTP id a16-20020a056a20145000b000b5e1f5c72fmr19748430pzi.28.1674233854951; Fri, 20 Jan 2023 08:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674233854; cv=none; d=google.com; s=arc-20160816; b=mtHPz8Mxlh3VQf/M5qvfYWQnBt8mx/o4E5jpyDqvdP8FGz+K11GATPvLj2UrIwQi1d VeAytnykmx+1EO2L8THEWROqqLgsJYYHqNWqB3XO0sZdjSZVk9i17VGG68ZEenjX3UTS RxMs7UIb8DNQyIhmq7BeubPuq60EwU46IJAdxIJkym5qFlf3hLlZvMzcDuTfPrI7MMok nxTQwhOu08H1kJ6/qM+aALgTXars5U1UmIlUDq6C1/J9HYTSOxdJ/U4+DQ0J4SxpOXh9 +q3a7+je6/1ovNiuZ1mY3f4T0ytWDqQMcQT778brceG94MswA6CwoLT67wo+0kY++pLn 3ilA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TnOBM38jwZ+FGGTAxzVN5OdFQ/WcRS5JKv2Bru4tdr8=; b=zD1M+H9nMaaLaDT3bl7UXzv6BURcrieYxUDm5cU1qYSP+ZauBKwnPt1LtSyh3RjU4Z 2ConuGAJX8zJmAUrPIY0xP6wsjAD+SFaE5OWvVg7XFnSEXXBczXJTat4rrWPPbfEbtnv vhwG9EEbdeMftpNMKpF81QpsiKC/soVm95PoRTfibCyalD2dQPZiBmAcPZsRVNh8gs51 PH7XW5Ev5WMZgi+doLk2oEJ72HFBK42qp9IziMeW7mrPRveXqGSF0/mKZSJjohOTdRaG Kr3f/p1RkiPAeqViN2qVazDU/Y39dW8LBeRDjRyHOQHoaCVgIf3rBB9p/fRY7EN6+Mzw WGxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=uDhE2Fr6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t190-20020a6381c7000000b004cff4e7799dsi10221049pgd.813.2023.01.20.08.57.28; Fri, 20 Jan 2023 08:57:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20210112.gappssmtp.com header.s=20210112 header.b=uDhE2Fr6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229804AbjATQ0Y (ORCPT + 50 others); Fri, 20 Jan 2023 11:26:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229648AbjATQ0V (ORCPT ); Fri, 20 Jan 2023 11:26:21 -0500 Received: from mail-qt1-x82e.google.com (mail-qt1-x82e.google.com [IPv6:2607:f8b0:4864:20::82e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1267F8B33C for ; Fri, 20 Jan 2023 08:26:17 -0800 (PST) Received: by mail-qt1-x82e.google.com with SMTP id e8so4542126qts.1 for ; Fri, 20 Jan 2023 08:26:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20210112.gappssmtp.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TnOBM38jwZ+FGGTAxzVN5OdFQ/WcRS5JKv2Bru4tdr8=; b=uDhE2Fr6pAyRvn4tBict9MP4d2ra+jv8S9DMqUwr+GSL64JdbxrXZf6Cx76qgUDgM2 mYadOfTh1BOW0ZZL4VHqwiQUZIdM/5Rc3h9ML0BxmsXHOu3iivCixvZ7E1CPE7A2EL// W0g0krEFMSuAUmt+GX0lICCqV3ZC2x4Ir8pnOAbr828oPDT3skVRpBnTNwqfZ/SoK32M siSbDnUIolNxfFXlSz/nRoBA/2vPTHZyIPjYll/Qj0mQBzAAdzHl1HyGN90Bz9XmZL93 tgsKjxeaFpir0zolamftaNQK7KI7NYBmV6Ln6VP5kzxUoKFQo9rfBNvEjdx6IQGQ5EXD YSIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TnOBM38jwZ+FGGTAxzVN5OdFQ/WcRS5JKv2Bru4tdr8=; b=EvymGTuGVe/KRCACMK9U6l1NKaZDvflzaom1Io10XVyXVyUPYzodA0zO1gDekvA7r8 6YMPEpkC57WitTAzC5O7RsRlVWMyERmy71VXKVDezF7Ex3omIWREwywYp9+cb5YzSXVi /8cNfJQJP5U7DAzlRJiC6Yh4cEnHO757k5s5TCR4f1HGXZjaS4bUN6CI9lZu+fjNNSYd aC/dM24ARqeGDWosd6GccK250bHwKVewImg88cYOkAhnMsHiWztKjUb/5QXcDJG0xtfm qnsa1+mZdrSTWwtpsCDVGxwvS3E8byxkUGthnUrA3Cbg/6tnKP0LkcIs8rq1hIJCdCFa i9Pw== X-Gm-Message-State: AFqh2koTML8j4qZkzrnq5gBzwIXskGG3tuhPZEQkFFYH7DST5qAxqOR5 r+dPR9OkfpS3TSKOAPzRo0bSZQ== X-Received: by 2002:a05:622a:4a83:b0:3a8:55c:a893 with SMTP id fw3-20020a05622a4a8300b003a8055ca893mr23602349qtb.0.1674231976245; Fri, 20 Jan 2023 08:26:16 -0800 (PST) Received: from localhost ([2620:10d:c091:480::1:bbe8]) by smtp.gmail.com with ESMTPSA id ca24-20020a05622a1f1800b003b697038179sm1564546qtb.35.2023.01.20.08.26.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 08:26:15 -0800 (PST) Date: Fri, 20 Jan 2023 11:27:12 -0500 From: Johannes Weiner To: Brian Foster Cc: Nhat Pham , akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, willy@infradead.org, linux-api@vger.kernel.org, kernel-team@meta.com, Yu Zhao Subject: Re: [PATCH v6 1/3] workingset: refactor LRU refault to expose refault recency check Message-ID: References: <20230117195959.29768-1-nphamcs@gmail.com> <20230117195959.29768-2-nphamcs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 20, 2023 at 09:34:18AM -0500, Brian Foster wrote: > On Tue, Jan 17, 2023 at 11:59:57AM -0800, Nhat Pham wrote: > > + int memcgid; > > + struct pglist_data *pgdat; > > + unsigned long token; > > + > > + unpack_shadow(shadow, &memcgid, &pgdat, &token, workingset); > > + eviction_memcg = mem_cgroup_from_id(memcgid); > > + > > + lruvec = mem_cgroup_lruvec(eviction_memcg, pgdat); > > + lrugen = &lruvec->lrugen; > > + > > + min_seq = READ_ONCE(lrugen->min_seq[file]); > > + return !((token >> LRU_REFS_WIDTH) != (min_seq & (EVICTION_MASK >> LRU_REFS_WIDTH))); > > I think this might be more readable without the double negative. > > Also it looks like this logic is pulled from lru_gen_refault(). Any > reason the caller isn't refactored to use this helper, similar to how > workingset_refault() is modified? It seems like a potential landmine to > duplicate the logic here for cachestat purposes and somewhere else for > actual workingset management. The initial version was refactored. Yu explicitly requested it be duplicated [1] to cut down on some boiler plate. I have to agree with Brian on this one, though. The factored version is better for maintenance than duplicating the core logic here. Even if it ends up a bit more boiler plate - it's harder to screw that up, and easier to catch at compile time, than the duplicates diverging. [1] https://lore.kernel.org/lkml/CAOUHufZKTqoD2rFwrX9-eCknBmeWqP88rZ7X7A_5KHHbGBUP=A@mail.gmail.com/