Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1650729rdd; Thu, 11 Jan 2024 05:41:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdA2rfPNVAGf1u8osQRFw5T3F0pygkj7y7Kfc0Bsr0vucfcWkUiLnFRuiy7m5Bh39xzwL6 X-Received: by 2002:a05:620a:2948:b0:783:35d5:2bb with SMTP id n8-20020a05620a294800b0078335d502bbmr1629611qkp.60.1704980497275; Thu, 11 Jan 2024 05:41:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704980497; cv=none; d=google.com; s=arc-20160816; b=b9DtFIZL1RTXHSpvY+glWR+WugePjHLOxZVxit5QvmzI+rMVuynh13umWvhWu2PBLc cts/phAM7EGopm7yjPrTO+zIxWaLiHtFa8H8QcvRFrTNZrhBYctKDYxYrhkRlsyGQT5U SiuO4E9c0Qe9pL/gfyxS/WpBb65x27AOXjOM2IHt/epw3pZWT2VVRsB6vRdaPXDqNWRy 287TYYzRlpfl+lqRpqtvPhMbtrwrAZv5a0X9A/wDv7eJZI1bR51z0q6f7kF3GY8Aj5aW cB3ss05qHaI8mubunobBPmdf2dnF96r0A6bPNxDs4cqMzOZ7r3vvUTKwh84XWHy+NXJ4 695Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=OrNtFKBOME8koezo+hwmifmOEhoB9oiYKEx7YwjL4r0=; fh=GlEP0vHYJXp1f+3CQU0rPtbTKSMHwzEocv9Q2rJaxss=; b=gZsiBglryB8CpHquTfNQQh03BzxGRGup0b5ztzEEHgJ0cF0d3zxMuCqlnlNS7+j1+h RY3Z9SQnzPo0DzMe98SVnaM8eaZFL73y3aSKu/aopXSUC5WhdfW52fj3QFkwqfwKMOmX hXifp+83/23tKakhqaxPjvCZsvp7DjJTcCqqTRCmPdT6llDXraek1dEGCPVa8/t1AHlq 4cGIjI74J/5Qy5K3PzLXlWRSZj+6XHMKDujC5Yzx97YtWVJCT+jCLWce0AomV4vae4bi 30YcipFcsbIg0QWDuFJKM6zIiD0y/gavabAdcPA7k5y8rtjMInHKJ2ty/3s6OYlJUYIV bVfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=Md1WfQW3; spf=pass (google.com: domain of linux-kernel+bounces-23670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23670-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v11-20020a05620a090b00b007815f50b903si914606qkv.188.2024.01.11.05.41.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 05:41:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@cmpxchg-org.20230601.gappssmtp.com header.s=20230601 header.b=Md1WfQW3; spf=pass (google.com: domain of linux-kernel+bounces-23670-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23670-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id F27981C23BAF for ; Thu, 11 Jan 2024 13:41:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 971071863C; Thu, 11 Jan 2024 13:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20230601.gappssmtp.com header.i=@cmpxchg-org.20230601.gappssmtp.com header.b="Md1WfQW3" Received: from mail-qk1-f173.google.com (mail-qk1-f173.google.com [209.85.222.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CD2C1802D for ; Thu, 11 Jan 2024 13:41:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cmpxchg.org Received: by mail-qk1-f173.google.com with SMTP id af79cd13be357-78333ad3a17so221936285a.3 for ; Thu, 11 Jan 2024 05:41:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20230601.gappssmtp.com; s=20230601; t=1704980487; x=1705585287; darn=vger.kernel.org; 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=OrNtFKBOME8koezo+hwmifmOEhoB9oiYKEx7YwjL4r0=; b=Md1WfQW3oPsFkg6vpOhZrmtHl5kDxwloz/s5glmryxJQTCqbzWBUpgzGH0Wnyrkby6 wFeNIK8EexuR+4vP7g9Titz22eV4L6VXvDWiAakFfJNr2PBnxvYelFWOXV+2+6QDcW8b 89uB6CiAtfgdH6ik8/eS4YqWAfzwNR/P1O8JI0nH5kKF3qTvQCgfIxTJ4/5YU7HdQnSD uMcIklSEN8FUGu3zSMHSyiQTA+JcnL/63HExfZG6O41SGjIuDykS81moiDT6KRQnTw28 EA4YXB9462mweNselERLKCm8P9so2odlxUuQqAHPGpQbPd8y0CvwPCeM9+xFkYaKcpnP 0VVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704980487; x=1705585287; 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=OrNtFKBOME8koezo+hwmifmOEhoB9oiYKEx7YwjL4r0=; b=vwKSg18vhtZOgg56u+lH/WQOrBAFFKwAYF1oS6G2GSB39NnhQ3jjrH5aupg3B4sKtO 9DGgIoPfiLf5hHW+kn8DHrQo0LjDUPsMbPxg5WPxQN2usIR2nhDWl9EWcVtjuB04V2Xb 11nFEnN7uuzLPzHoCmjjBAg1c/m0KqEPMDXYB/9zD92baXWaOFny8b7YP80EZ5j7dOrj p+1m3vQnhVm6WnBUUhqjvWAH/z53H/gjLrEmusgdATlc04dtVF3zwmD+Tv/6jAgpC/2/ 0KLA51aO9ZkvqtcFtlQJKkIAJCmCm1cba5DLqEIbY7Ypj6snQOu/G9UNR31+2UBfZ06A xFzA== X-Gm-Message-State: AOJu0YxivcblaALTl8wQvwDYfInhDkCxogzyv/Dtx0MMO65ooV9cqbx4 sI0PpFAHJzaFN7ElPJlAWZ2co9E9HHyIlw== X-Received: by 2002:a05:620a:8082:b0:781:62f6:6786 with SMTP id ef2-20020a05620a808200b0078162f66786mr1335682qkb.127.1704980486804; Thu, 11 Jan 2024 05:41:26 -0800 (PST) Received: from localhost (2603-7000-0c01-2716-da5e-d3ff-fee7-26e7.res6.spectrum.com. [2603:7000:c01:2716:da5e:d3ff:fee7:26e7]) by smtp.gmail.com with ESMTPSA id ay13-20020a05620a178d00b0078318dac889sm345703qkb.19.2024.01.11.05.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 05:41:26 -0800 (PST) Date: Thu, 11 Jan 2024 08:41:25 -0500 From: Johannes Weiner To: Zhiguo Jiang Cc: Andrew Morton , David Hildenbrand , Matthew Wilcox , Chris Li , Michal Hocko , Kefeng Wang , Dan Schatzberg , Yosry Ahmed , Yue Zhao , Hugh Dickins , linux-kernel@vger.kernel.org, linux-mm@kvack.org, opensource.kernel@vivo.com Subject: Re: [PATCH v1 1/2] mm:vmscan: fix workingset eviction memcg issue Message-ID: <20240111134125.GA390292@cmpxchg.org> References: <20240111122451.682-1-justinjiang@vivo.com> <20240111122451.682-2-justinjiang@vivo.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240111122451.682-2-justinjiang@vivo.com> On Thu, Jan 11, 2024 at 08:24:50PM +0800, Zhiguo Jiang wrote: > The parameter of target_memcg is NULL in workingset_eviction(), and > the lruvec obtained by mem_cgroup_lruvec(target_memcg, pgdat) is always > root_mem_cgroup->lruvec, rather than the lruvec of mem_cgroup where > folio is actually located. WTF? No! /* * The memory cgroup that hit its limit and as a result is the * primary target of this reclaim invocation. */ struct mem_cgroup *target_mem_cgroup; The cgroup that is stored in the eviction cookie is the one whose limit triggered the reclaim cycle. This is often several levels above the cgroups that own the pages. Subsequent refaults need to be evaluated at the eviction level: /* * The activation decision for this folio is made at the level * where the eviction occurred, as that is where the LRU order * during folio reclaim is being determined. * * However, the cgroup that will own the folio is the one that * is actually experiencing the refault event. */ > Fix target_memcg to the memcg obtained by folio_memcg(folio). > > Signed-off-by: Zhiguo Jiang Nacked-by: Johannes Weiner Please take more time to read into the code you're proposing to change. You made it sound like a trivial simplification, but this totally screws up aging and pressure detection in containers.