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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 F183DC433ED for ; Thu, 15 Apr 2021 10:02:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C5516611AD for ; Thu, 15 Apr 2021 10:02:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230290AbhDOKDA (ORCPT ); Thu, 15 Apr 2021 06:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbhDOKCp (ORCPT ); Thu, 15 Apr 2021 06:02:45 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64FDDC061574 for ; Thu, 15 Apr 2021 03:02:21 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d8so11760896plh.11 for ; Thu, 15 Apr 2021 03:02:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zm6WOLpoBupP5HjBPdb3l9pYDvQOSku0pOkw8t2295U=; b=j4Iyb3iIzlUmiMrepUSmxPvgLsBjtBUY9oW1JFiiGooOW/MM7tJyI686cDprjLhKhG 0RxNwyJ6DSqcxWRpM+qG96okUZ00v72RSqY9S38fwz3Y6bQczIUSvLx4H72t5hqWNBo9 DyhISgnfnVl2NYzMRRsjwRyR/FavV8c3pGIydbSVC8Qb7TLnOEFmZ9qv8iMKxH9Fqzyr GIhXpaXZ+tXYz/N7a+fhIWjtR+FCjUNL58PUn7yHtrodKkmvhHxYa5+08EjEGRO9XiV+ RW+oTqd1p+ecNFZDRpo+NpNk1Okp1hnmYKO+q85wyrTk3COEVbqsYzi/pfFxCcAuNXUu zWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Zm6WOLpoBupP5HjBPdb3l9pYDvQOSku0pOkw8t2295U=; b=mNOYsc8yPvXG4PjCbfdWFV9v/MpYBg5lUZEaqIz44N7RU9wCZ5+yN9PL3Ki2KDYJBN vnxx5WT/1lOsWm7pZG3Hm1veIuaRO4e7ZJYxXyJjNlZyabXUqhFg5EQeuGPMtbkkc4fy Gl/4iWT1vlK//pyofO7KVEk1L6CPxPhWE4BqUV8cyOlJ+2uQIkHa9aOp6zlcRyXQo6x8 JH9sBZ5UTXU/AaWruqIhBrNPIEErdyz/e3wD3vp9ZyAuwlfveYM+vCjdgv0XEjrL8XVV r2Of9n98D5t0/nWx56W1OOCJPlo/FbWyZwLN464ydADFQv5Jq4zcXqd1iA352mUz0yX8 brBQ== X-Gm-Message-State: AOAM531nfG55sDhb9fHhQalL8ClPbTNZ4H1en2O727GjIXJVo+b7BqJi CDy05f5YQQixV1Pa7Po/amxHyhzMOSLm9Bfx27fEPA== X-Google-Smtp-Source: ABdhPJzIqo/dJxuaB4eMFPaHL4ZYJTOustyDLlI9/weAm8+moE/xsKoxTvOPspHWx9D3rPi459BckDQzTdfnDVLt/eI= X-Received: by 2002:a17:902:ea93:b029:eb:65ee:ddd3 with SMTP id x19-20020a170902ea93b02900eb65eeddd3mr3020294plb.24.1618480936088; Thu, 15 Apr 2021 03:02:16 -0700 (PDT) MIME-Version: 1.0 References: <20210413065153.63431-1-songmuchun@bytedance.com> <20210413065153.63431-5-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Thu, 15 Apr 2021 18:01:38 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 4/7] mm: memcontrol: simplify lruvec_holds_page_lru_lock To: Johannes Weiner Cc: Michal Hocko , Roman Gushchin , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List , Xiongchun duan , fam.zheng@bytedance.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 15, 2021 at 1:49 AM Johannes Weiner wrote: > > On Wed, Apr 14, 2021 at 06:00:42PM +0800, Muchun Song wrote: > > On Wed, Apr 14, 2021 at 5:44 PM Michal Hocko wrote: > > > > > > On Tue 13-04-21 14:51:50, Muchun Song wrote: > > > > We already have a helper lruvec_memcg() to get the memcg from lruvec, we > > > > do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So use > > > > lruvec_memcg() instead. And if mem_cgroup_disabled() returns false, the > > > > page_memcg(page) (the LRU pages) cannot be NULL. So remove the odd logic > > > > of "memcg = page_memcg(page) ? : root_mem_cgroup". And use lruvec_pgdat > > > > to simplify the code. We can have a single definition for this function > > > > that works for !CONFIG_MEMCG, CONFIG_MEMCG + mem_cgroup_disabled() and > > > > CONFIG_MEMCG. > > > > > > Neat. While you are at it wouldn't it make sesne to rename the function > > > as well. I do not want to bikeshed but this is really a misnomer. it > > > doesn't check anything about locking. page_belongs_lruvec? > > > > Right. lruvec_holds_page_lru_lock is used to check whether > > the page belongs to the lruvec. page_belongs_lruvec > > obviously more clearer. I can rename it to > > page_belongs_lruvec the next version. > > This sounds strange to me, I think 'belongs' needs a 'to' to be > correct, so page_belongs_to_lruvec(). Still kind of a mouthful. > > page_matches_lruvec()? > I prefer this name. If you also agree, I will use this name. Thanks. > page_from_lruvec()? 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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 60DAAC433B4 for ; Thu, 15 Apr 2021 10:02:20 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C84A4611AD for ; Thu, 15 Apr 2021 10:02:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C84A4611AD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4D96D6B0036; Thu, 15 Apr 2021 06:02:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49DE86B006C; Thu, 15 Apr 2021 06:02:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 33F056B0070; Thu, 15 Apr 2021 06:02:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0065.hostedemail.com [216.40.44.65]) by kanga.kvack.org (Postfix) with ESMTP id 13BE86B0036 for ; Thu, 15 Apr 2021 06:02:19 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id BC51C18C9 for ; Thu, 15 Apr 2021 10:02:18 +0000 (UTC) X-FDA: 78034161156.04.D58D9FB Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf08.hostedemail.com (Postfix) with ESMTP id 3693880192FB for ; Thu, 15 Apr 2021 10:02:03 +0000 (UTC) Received: by mail-pl1-f173.google.com with SMTP id w8so9432693plg.9 for ; Thu, 15 Apr 2021 03:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Zm6WOLpoBupP5HjBPdb3l9pYDvQOSku0pOkw8t2295U=; b=j4Iyb3iIzlUmiMrepUSmxPvgLsBjtBUY9oW1JFiiGooOW/MM7tJyI686cDprjLhKhG 0RxNwyJ6DSqcxWRpM+qG96okUZ00v72RSqY9S38fwz3Y6bQczIUSvLx4H72t5hqWNBo9 DyhISgnfnVl2NYzMRRsjwRyR/FavV8c3pGIydbSVC8Qb7TLnOEFmZ9qv8iMKxH9Fqzyr GIhXpaXZ+tXYz/N7a+fhIWjtR+FCjUNL58PUn7yHtrodKkmvhHxYa5+08EjEGRO9XiV+ RW+oTqd1p+ecNFZDRpo+NpNk1Okp1hnmYKO+q85wyrTk3COEVbqsYzi/pfFxCcAuNXUu zWCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Zm6WOLpoBupP5HjBPdb3l9pYDvQOSku0pOkw8t2295U=; b=N61myFiqxGKhAq/fgTvh2lqUgbR0fFbTy6Bq3yXxM9lQgdr+ChUXuRZUdNsSzmK3oP vKIne5ASbeofwUTTGsvzB6IUvxqmYqD0GivVqIgfwW4vyVtodudLvJLiitthLsq2MHuF FpWgyFsdQuA8jCK7JLAP1ONwZ6mVVOnmGNAEbb4F1bkVUJUGk002s9gJT+9w3qTj8fFb UYEnMsid3eUJ5BtBS1j6IDbF4o5OBD4nPg/AG4JVZATGk3o2PQDjAE76SkH/5WF6KBVM 9lHG303/p/lhJf3qFzKFPyYxMjtia4iaWL6Snt8nBwJPCZdXsysPUlMu1CjOn35lgoDY di8w== X-Gm-Message-State: AOAM532CIzjhMcfCp1wodIQWvSTONhekeLiVtgYP+AOfy1N8+BrHHvdZ JFfynCerVDqwhh4Hmg2ByymlTqJBPenz1MtzbF0dqg== X-Google-Smtp-Source: ABdhPJzIqo/dJxuaB4eMFPaHL4ZYJTOustyDLlI9/weAm8+moE/xsKoxTvOPspHWx9D3rPi459BckDQzTdfnDVLt/eI= X-Received: by 2002:a17:902:ea93:b029:eb:65ee:ddd3 with SMTP id x19-20020a170902ea93b02900eb65eeddd3mr3020294plb.24.1618480936088; Thu, 15 Apr 2021 03:02:16 -0700 (PDT) MIME-Version: 1.0 References: <20210413065153.63431-1-songmuchun@bytedance.com> <20210413065153.63431-5-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Thu, 15 Apr 2021 18:01:38 +0800 Message-ID: Subject: Re: [External] Re: [PATCH 4/7] mm: memcontrol: simplify lruvec_holds_page_lru_lock To: Johannes Weiner Cc: Michal Hocko , Roman Gushchin , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List , Xiongchun duan , fam.zheng@bytedance.com Content-Type: text/plain; charset="UTF-8" X-Stat-Signature: f46nmccwa8zf4ubr6eid9ug5y11q81xh X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 3693880192FB Received-SPF: none (bytedance.com>: No applicable sender policy available) receiver=imf08; identity=mailfrom; envelope-from=""; helo=mail-pl1-f173.google.com; client-ip=209.85.214.173 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618480923-11686 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Apr 15, 2021 at 1:49 AM Johannes Weiner wrote: > > On Wed, Apr 14, 2021 at 06:00:42PM +0800, Muchun Song wrote: > > On Wed, Apr 14, 2021 at 5:44 PM Michal Hocko wrote: > > > > > > On Tue 13-04-21 14:51:50, Muchun Song wrote: > > > > We already have a helper lruvec_memcg() to get the memcg from lruvec, we > > > > do not need to do it ourselves in the lruvec_holds_page_lru_lock(). So use > > > > lruvec_memcg() instead. And if mem_cgroup_disabled() returns false, the > > > > page_memcg(page) (the LRU pages) cannot be NULL. So remove the odd logic > > > > of "memcg = page_memcg(page) ? : root_mem_cgroup". And use lruvec_pgdat > > > > to simplify the code. We can have a single definition for this function > > > > that works for !CONFIG_MEMCG, CONFIG_MEMCG + mem_cgroup_disabled() and > > > > CONFIG_MEMCG. > > > > > > Neat. While you are at it wouldn't it make sesne to rename the function > > > as well. I do not want to bikeshed but this is really a misnomer. it > > > doesn't check anything about locking. page_belongs_lruvec? > > > > Right. lruvec_holds_page_lru_lock is used to check whether > > the page belongs to the lruvec. page_belongs_lruvec > > obviously more clearer. I can rename it to > > page_belongs_lruvec the next version. > > This sounds strange to me, I think 'belongs' needs a 'to' to be > correct, so page_belongs_to_lruvec(). Still kind of a mouthful. > > page_matches_lruvec()? > I prefer this name. If you also agree, I will use this name. Thanks. > page_from_lruvec()?