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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 E9ACFC4707F for ; Wed, 26 May 2021 02:49:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC6CD61432 for ; Wed, 26 May 2021 02:49:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbhEZCvS (ORCPT ); Tue, 25 May 2021 22:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbhEZCvR (ORCPT ); Tue, 25 May 2021 22:51:17 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F08BCC061574 for ; Tue, 25 May 2021 19:49:44 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id x18so20829364pfi.9 for ; Tue, 25 May 2021 19:49:44 -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=2BepZnCkcUmGhQ5OjwD1VB02wV2VKA/owewc6BO/X1Y=; b=DDmq7hQ0ghVGWObwNW2j54M3a6BBUK6YgYXiFDgE/1LUF3TVDNic2ox+7j6NRkepE2 yI2s7tDtlPv+f4cgn59M8gGrFY5oNNnCcbyliWqRSntAZdz8z8T/P20djEyMlPywkkHv rdrJdzQ5OhY1mFFg9t0VUcpzEe1ZraHVLxID29+JvKSDjihPv+sf4AZDr3pcobUya5Sy /fcBeRb2bjpH9JIP36gkbwERmQeXtSRV4jKVLC5jqkaqirTNObH4b7GjjNjZL5J98kHX e/WFuuJpP6ayvJzZdkd73crm5jHJOqGrRVzcQfF80up3W/jn2ny9nZbzX4Ka9ELQwJvI QJFw== 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=2BepZnCkcUmGhQ5OjwD1VB02wV2VKA/owewc6BO/X1Y=; b=XplOSMVia9D8OJG2fyQmTHhy8h9Ayg7LIZWONANy0XT27/JOjxJU0AWVmRsxh9o7PP Kk/lP887969r1hYzHtdnFKEeG9t1eo/Qv/5Q/vUNbLnYG6YYAFC7A4OjucYxMWyT9uJp DGfHVGcPXYM2Y30DqWVeLgBgM2Ims1wk/WwONmMPf0Q1U6Yz4RZl+37ewRFUCeQR+wUr 0CfqJKjHNuD5RfyafCzMyP87lTXxcvIH/N7iI9otbs+oxqHzBQ0lw7Avk2uiUG53waz5 Sf8dmiHv3vFfwdgfLOh6nl7ASW88/N7htb7zuHA/sa/69HoCHgrazbJsK5cpiJC5doYz C98Q== X-Gm-Message-State: AOAM530yYadVohwdjwsFNkHndc43hY34kclThl4TXq58qungQ5Yqkavr EtPF5EvJQgSu5qQ1kSvPwouwnt7M65DSZBB/9jX+Fg== X-Google-Smtp-Source: ABdhPJx7cPc0O2UrFrGyIQ+PbMrQwFRfUkTEdyu0u54IUeYn/MLLF/V39FIJVJEulczW9iJpLwXOLxLq7cKeyiXb+Zg= X-Received: by 2002:a63:6547:: with SMTP id z68mr15614319pgb.341.1621997384564; Tue, 25 May 2021 19:49:44 -0700 (PDT) MIME-Version: 1.0 References: <20210421070059.69361-1-songmuchun@bytedance.com> <20210421070059.69361-3-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Wed, 26 May 2021 10:49:08 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH v3 02/12] mm: memcontrol: introduce compact_lock_page_lruvec_irqsave To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List , Xiongchun duan , fam.zheng@bytedance.com, "Singh, Balbir" , Yang Shi , Alex Shi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 26, 2021 at 1:21 AM Roman Gushchin wrote: > > On Wed, Apr 21, 2021 at 03:00:49PM +0800, Muchun Song wrote: > > If we reuse the objcg APIs to charge LRU pages, the page_memcg() > > can be changed when the LRU pages reparented. In this case, we need > > to acquire the new lruvec lock. > > > > lruvec = mem_cgroup_page_lruvec(page); > > > > // The page is reparented. > > > > compact_lock_irqsave(&lruvec->lru_lock, &flags, cc); > > > > // Acquired the wrong lruvec lock and need to retry. > > > > But compact_lock_irqsave() only take lruvec lock as the parameter, > > we cannot aware this change. If it can take the page as parameter > > to acquire the lruvec lock. When the page memcg is changed, we can > > use the page_memcg() detect whether we need to reacquire the new > > lruvec lock. So compact_lock_irqsave() is not suitable for us. > > Similar to lock_page_lruvec_irqsave(), introduce > > compact_lock_page_lruvec_irqsave() to acquire the lruvec lock in > > the compaction routine. > > > > Signed-off-by: Muchun Song > > Acked-by: Roman Gushchin Thanks. > > > --- > > mm/compaction.c | 27 ++++++++++++++++++++++++--- > > 1 file changed, 24 insertions(+), 3 deletions(-) > > > > diff --git a/mm/compaction.c b/mm/compaction.c > > index 1c500e697c88..082293587cc6 100644 > > --- a/mm/compaction.c > > +++ b/mm/compaction.c > > @@ -511,6 +511,29 @@ static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags, > > return true; > > } > > > > +static struct lruvec * > > +compact_lock_page_lruvec_irqsave(struct page *page, unsigned long *flags, > > + struct compact_control *cc) > > Maybe compact_lock_page_irqsave() to make it more similar to > compact_lock_irqsafe()? But it's up to you. I like a more brief name, compact_lock_page_irqsave is a good and brief name. Thanks. > > Thanks! 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=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 77C44C47087 for ; Wed, 26 May 2021 02:49:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 22F6861090 for ; Wed, 26 May 2021 02:49:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 22F6861090 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 A4A2C6B0036; Tue, 25 May 2021 22:49:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9F9CD6B006E; Tue, 25 May 2021 22:49:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 825E16B0070; Tue, 25 May 2021 22:49:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0005.hostedemail.com [216.40.44.5]) by kanga.kvack.org (Postfix) with ESMTP id 46A256B0036 for ; Tue, 25 May 2021 22:49:46 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E2A668249980 for ; Wed, 26 May 2021 02:49:45 +0000 (UTC) X-FDA: 78181851930.18.0C7B044 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf04.hostedemail.com (Postfix) with ESMTP id 050412C2 for ; Wed, 26 May 2021 02:49:41 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id d78so24255704pfd.10 for ; Tue, 25 May 2021 19:49:45 -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=2BepZnCkcUmGhQ5OjwD1VB02wV2VKA/owewc6BO/X1Y=; b=DDmq7hQ0ghVGWObwNW2j54M3a6BBUK6YgYXiFDgE/1LUF3TVDNic2ox+7j6NRkepE2 yI2s7tDtlPv+f4cgn59M8gGrFY5oNNnCcbyliWqRSntAZdz8z8T/P20djEyMlPywkkHv rdrJdzQ5OhY1mFFg9t0VUcpzEe1ZraHVLxID29+JvKSDjihPv+sf4AZDr3pcobUya5Sy /fcBeRb2bjpH9JIP36gkbwERmQeXtSRV4jKVLC5jqkaqirTNObH4b7GjjNjZL5J98kHX e/WFuuJpP6ayvJzZdkd73crm5jHJOqGrRVzcQfF80up3W/jn2ny9nZbzX4Ka9ELQwJvI QJFw== 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=2BepZnCkcUmGhQ5OjwD1VB02wV2VKA/owewc6BO/X1Y=; b=SzPB0jihCExTBd0xomJ33/ElAIIVT0am9S8XRidC7o/WGWsqBkqyY8Ne1cw/FFtSYy b9TnOZ+O+mBkEGu3uMGLdJO1n8v7nzNMqTnbehC/43FXtmApRKUQhJ1apJdfu59Q46na p0TyMnHjQoJ5qbiljLk1j5DP4PqnPaNjLiXUPOEP8UBHC77UK7Hq+mzd14F7EMjEmPm2 Da1E9vA1XjQ1LbZffY8WY4CnTv2KbhpX0W+V7zWv5SFwk+HiTFV2hNb0wXoRK/tbeh1d uf2c6onogca+8rrl1/wfNUXWcfdWTdTaYBjYhryoo7uFeu39PBjf//IBAKWVr1AiNAjY u7sw== X-Gm-Message-State: AOAM5321ZSrJ2EqJNNqJu//qwAWvnrFQlyTT9VZjC8Mn+ckIc7ZNBALX bRWqmtMMaY1JdWRYItIPXlrqQzRbKcHvBIzkErIt1Q== X-Google-Smtp-Source: ABdhPJx7cPc0O2UrFrGyIQ+PbMrQwFRfUkTEdyu0u54IUeYn/MLLF/V39FIJVJEulczW9iJpLwXOLxLq7cKeyiXb+Zg= X-Received: by 2002:a63:6547:: with SMTP id z68mr15614319pgb.341.1621997384564; Tue, 25 May 2021 19:49:44 -0700 (PDT) MIME-Version: 1.0 References: <20210421070059.69361-1-songmuchun@bytedance.com> <20210421070059.69361-3-songmuchun@bytedance.com> In-Reply-To: From: Muchun Song Date: Wed, 26 May 2021 10:49:08 +0800 Message-ID: Subject: Re: [External] Re: [RFC PATCH v3 02/12] mm: memcontrol: introduce compact_lock_page_lruvec_irqsave To: Roman Gushchin Cc: Johannes Weiner , Michal Hocko , Andrew Morton , Shakeel Butt , Vladimir Davydov , LKML , Linux Memory Management List , Xiongchun duan , fam.zheng@bytedance.com, "Singh, Balbir" , Yang Shi , Alex Shi Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=bytedance-com.20150623.gappssmtp.com header.s=20150623 header.b=DDmq7hQ0; spf=pass (imf04.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 050412C2 X-Stat-Signature: fs8jqygobxps9go1tbir1wwf513c33qx X-HE-Tag: 1621997381-528180 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 Wed, May 26, 2021 at 1:21 AM Roman Gushchin wrote: > > On Wed, Apr 21, 2021 at 03:00:49PM +0800, Muchun Song wrote: > > If we reuse the objcg APIs to charge LRU pages, the page_memcg() > > can be changed when the LRU pages reparented. In this case, we need > > to acquire the new lruvec lock. > > > > lruvec = mem_cgroup_page_lruvec(page); > > > > // The page is reparented. > > > > compact_lock_irqsave(&lruvec->lru_lock, &flags, cc); > > > > // Acquired the wrong lruvec lock and need to retry. > > > > But compact_lock_irqsave() only take lruvec lock as the parameter, > > we cannot aware this change. If it can take the page as parameter > > to acquire the lruvec lock. When the page memcg is changed, we can > > use the page_memcg() detect whether we need to reacquire the new > > lruvec lock. So compact_lock_irqsave() is not suitable for us. > > Similar to lock_page_lruvec_irqsave(), introduce > > compact_lock_page_lruvec_irqsave() to acquire the lruvec lock in > > the compaction routine. > > > > Signed-off-by: Muchun Song > > Acked-by: Roman Gushchin Thanks. > > > --- > > mm/compaction.c | 27 ++++++++++++++++++++++++--- > > 1 file changed, 24 insertions(+), 3 deletions(-) > > > > diff --git a/mm/compaction.c b/mm/compaction.c > > index 1c500e697c88..082293587cc6 100644 > > --- a/mm/compaction.c > > +++ b/mm/compaction.c > > @@ -511,6 +511,29 @@ static bool compact_lock_irqsave(spinlock_t *lock, unsigned long *flags, > > return true; > > } > > > > +static struct lruvec * > > +compact_lock_page_lruvec_irqsave(struct page *page, unsigned long *flags, > > + struct compact_control *cc) > > Maybe compact_lock_page_irqsave() to make it more similar to > compact_lock_irqsafe()? But it's up to you. I like a more brief name, compact_lock_page_irqsave is a good and brief name. Thanks. > > Thanks!