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=-10.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,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 3D796C433E0 for ; Mon, 22 Feb 2021 18:40:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A3C9A64DBD for ; Mon, 22 Feb 2021 18:40:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A3C9A64DBD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1B8786B006E; Mon, 22 Feb 2021 13:40:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 167966B0070; Mon, 22 Feb 2021 13:40:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02F096B0073; Mon, 22 Feb 2021 13:40:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0170.hostedemail.com [216.40.44.170]) by kanga.kvack.org (Postfix) with ESMTP id E1CA36B006E for ; Mon, 22 Feb 2021 13:40:16 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 9BEFC180ACF9A for ; Mon, 22 Feb 2021 18:40:16 +0000 (UTC) X-FDA: 77846768832.11.46E7721 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by imf01.hostedemail.com (Postfix) with ESMTP id 83F2F20003A8 for ; Mon, 22 Feb 2021 18:40:05 +0000 (UTC) IronPort-SDR: u12xCytHUp7rNwt7agkYlRXjm9XQlhoucCnYpY/fVFj+3uVAK+sbE6+pnc4wFnaAEnc7YmKN17 TRgXw6keNWXQ== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="203954413" X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="203954413" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 10:38:28 -0800 IronPort-SDR: K25ijc2ixE1JNZWZB66mWJ4ZdE0FII9vDWen8txowUjhmclpeg2toWWWFDqz3XnBN3+69ECDow o6Cz8fMw7CLg== X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="389966258" Received: from schen9-mobl.amr.corp.intel.com ([10.251.12.88]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 10:38:28 -0800 Subject: Re: [PATCH v2 3/3] mm: Fix missing mem cgroup soft limit tree updates To: Johannes Weiner Cc: Andrew Morton , Michal Hocko , Vladimir Davydov , Dave Hansen , Ying Huang , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org References: From: Tim Chen Message-ID: Date: Mon, 22 Feb 2021 10:38:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 83F2F20003A8 X-Stat-Signature: gzndhi4fkh93mrw3asdms7eyrduzs47k Received-SPF: none (linux.intel.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mga01.intel.com; client-ip=192.55.52.88 X-HE-DKIM-Result: none/none X-HE-Tag: 1614019205-226656 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 2/17/21 9:56 PM, Johannes Weiner wrote: >> static inline void uncharge_gather_clear(struct uncharge_gather *ug) >> @@ -6849,7 +6850,13 @@ static void uncharge_page(struct page *page, struct uncharge_gather *ug) >> * exclusive access to the page. >> */ >> >> - if (ug->memcg != page_memcg(page)) { >> + if (ug->memcg != page_memcg(page) || >> + /* >> + * Update soft limit tree used in v1 cgroup in page batch for >> + * the same node. Relevant only to v1 cgroup with a soft limit. >> + */ >> + (ug->dummy_page && ug->nid != page_to_nid(page) && >> + ug->memcg->soft_limit != PAGE_COUNTER_MAX)) { > > Sorry, I used weird phrasing in my last email. > > Can you please preface the checks you're adding with a > !cgroup_subsys_on_dfl(memory_cgrp_subsys) to static branch for > cgroup1? The uncharge path is pretty hot, and this would avoid the > runtime overhead on cgroup2 at least, which doesn't have the SL. > > Also, do we need the ug->dummy_page check? It's only NULL on the first > loop - where ug->memcg is NULL as well and the branch is taken anyway. > > The soft limit check is also slightly cheaper than the nid check, as > page_to_nid() might be out-of-line, so we should do it first. This? > > /* > * Batch-uncharge all pages of the same memcg. > * > * Unless we're looking at a cgroup1 with a softlimit > * set: the soft limit trees are maintained per-node > * and updated on uncharge (via dummy_page), so keep > * batches confined to a single node as well. > */ > if (ug->memcg != page_memcg(page) || > (!cgroup_subsys_on_dfl(memory_cgrp_subsys) && > ug->memcg->soft_limit != PAGE_COUNTER_MAX && > ug->nid != page_to_nid(page))) > Johannes, Thanks for your feedback. Since Michal has concerns about the overhead this patch could incur, I think we'll hold the patch for now. If later on Michal think that this patch is a good idea, I'll incorporate these changes you suggested. Tim