Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1844297pxb; Mon, 22 Feb 2021 12:25:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhhBWs0qIVzOhul5to8MJWkgQLzCcpjJQ/HYch5hWXpBqSMO4T2gIKl5gADXmutX4ekaoM X-Received: by 2002:aa7:d9d7:: with SMTP id v23mr20237871eds.320.1614025520094; Mon, 22 Feb 2021 12:25:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614025520; cv=none; d=google.com; s=arc-20160816; b=dfLGMDEi90NykY9BFayZ23mb8k0JTVcoDA1niUKwDHNiiAHQYmJtRVaP0zvLz2thbI pWqo9SM/2/sKF/YbdieaIY3bSipcCYDNwicuw5Q3sZ9kNfxuKU2EpovuNfNSMq94l2ZV vd/BCHn4I1Ev2gf+ZQGewqz/HVABWfcYHCMTeArtw8nVTwyHshbSNGU7ABeqTuU6nO1W FPiOc1l/5Ga0d6XUDVtrTscefcm3d4vFfjtnYnuO4BUqqy5IaZn4na6mazhXpJzuq/O4 E399cWCZp+fJbmefbtd1R8tdkP3wXQv2q7raqDRU1SQkzzJ8+MF3xFN5IfD0l1DgPW0k LzRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:ironport-sdr:ironport-sdr; bh=27WLfMzS6xIcmGLr6Mcu0AP5KrkTNOW04N5eI3jPIKg=; b=RRQ8j69t9JtZmyL6+00v2S5cmYX+DXCV9Spxq+xBXvsTEvb1UHoJDis8ji/CXaIa1l Uq3z82/R1e9mVAnt/9EYbaKsRb6Mb7unEX1zXk+2ZyHY551nKQbarGayLKa8BzIn5Cye W00NtOkDhOsaG3pDN/BbsaJ100kYeQCSH3mohrNaPdwPl0091lMuqtJgzg362sI20l9h rDCq/QFqDSuKsvDwmXmjmxxo5t6haLNzBevCsT6VWHI451SzBGLcF0CKxBOTgzFgVvX+ LN8cmaTqB1u/Runngd2cYPNFJtFqLKlSntw7EYpob2V0jHL2IFk5GN7m5bobWUpjP4Od Iqvw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la23si7045999ejb.505.2021.02.22.12.24.54; Mon, 22 Feb 2021 12:25:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231143AbhBVSky (ORCPT + 99 others); Mon, 22 Feb 2021 13:40:54 -0500 Received: from mga07.intel.com ([134.134.136.100]:65104 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231986AbhBVSkV (ORCPT ); Mon, 22 Feb 2021 13:40:21 -0500 IronPort-SDR: i54tMhGVkfVazDupSPUSQrubSX+R14TNYd3BqplGE2B2sbz0u5ewJ7mnxoYA/gxtcyOQBc5xbq zUosS8gw9rlA== X-IronPort-AV: E=McAfee;i="6000,8403,9903"; a="248604546" X-IronPort-AV: E=Sophos;i="5.81,197,1610438400"; d="scan'208";a="248604546" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Feb 2021 10:38:29 -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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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