From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f44.google.com (mail-qv1-f44.google.com [209.85.219.44]) (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 1D1BB2D0605 for ; Fri, 20 Mar 2026 14:24:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774016683; cv=none; b=Cyaqlcam4gMkUSUIjWOHbGEkP8/CCsPMLKVP7Kv0sO7OiC4nCPCTCZAt9elCII5DfLNl0hkbzyRsXmRTHTKGwMgRqaigI07C016khftOse4Q9oq0KjJBaj+bbOBt6RYHuFsypTQaKsxeAH6/HqZ/7iJMjMBmsXN4XodIWY0He7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774016683; c=relaxed/simple; bh=EM8rL4PYOhCMdvWQwI2rWV6mEwSwacsjj7Zf/J7r5rk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=D2cZkbQz2agzk1WBtKr/wJuXy8xscquyCNClt+KKflyF/2bgwQaOeTDo4fWBS3i/Ue//oKuIwI1DNBE/vGomxsChNdE1HE4GwkcZIXGuSLo9ES0LkvCkMkk33C2RgS3BTYW2C1GjZ/2J5LLcblB/8MtmcJbJu8WEJw1M+nbEC3A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cmpxchg.org; spf=pass smtp.mailfrom=cmpxchg.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b=twBnTzQA; arc=none smtp.client-ip=209.85.219.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg.org header.i=@cmpxchg.org header.b="twBnTzQA" Received: by mail-qv1-f44.google.com with SMTP id 6a1803df08f44-89c6a711ce9so10000236d6.0 for ; Fri, 20 Mar 2026 07:24:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg.org; s=google; t=1774016680; x=1774621480; 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=30KemMRkEtWLEEtm+zy29OVZD4hupOCTeFDDhcAE2FU=; b=twBnTzQAPG9On6N3k0WaFcdhGYaEtP9zps47soGCbwSCTp1UO8kLl40RJGFwwOQtqd XSBYhLnFcC10zlw3f4Czxf+X4HGNaB9w2VSN55+uoWdAVf4RrV2YvqGlSoUOVNygs+sF cjC+fJJG34hqdLfN9h2QOxXIEktcl3uUZ+t0wIx7gTKGyKHmor208OyJke3+kU/SQwC+ z6usbumIwZRRIpdG03LahP6B8YJNkFj4W3TEaupW0vwqXlQRfyFpRdWSsjmkP2FLk4Pd 6I487H7uPoyo0LNh0EVF6LKD4x6FY2BDaMvBW2APVteuNd5iutQQKPCKpNU2011AN7Ju M11g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774016680; x=1774621480; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=30KemMRkEtWLEEtm+zy29OVZD4hupOCTeFDDhcAE2FU=; b=haQ/Ye3itT+07asM129evXb4r7XtOzq+dKL1WoeJD9IVM9Ejr3Mzx1sh0p3fhfGZjg /+RqiTLndMiAfdbAamfB5MU38eidAo5fL33pz944sXduffykSxesK8UQ7v1hJNMhTgJk Vv+hLCk/ZsQA4KOsN8g28Nq7kT6dADPIYeagDmKgW5SGldWZnrbJWZGISK3irEGOeB6M nhkHPRvk+5qJPeZMRwrhHTpIJPCt7U0eKn8mkwo5SjeYXLpKxhDSDDt0qUhCOyi29E7c EusbJAuLP+SUc7lWCmA8P2jAhp+oSePAYDYbGLJ/INlRqejWbmaXNw3UmT76MtrwIAnr UP4A== X-Forwarded-Encrypted: i=1; AJvYcCVdBO7wR99hlBicFdW00Rg2y9omlJwDi4PZwpDG5cLW06uZYN7Cir6fl5jxXMOpPLVzj2H7v0H6c0y/TXk=@vger.kernel.org X-Gm-Message-State: AOJu0Ywb4c1bU06YcoDhlrdydm5wwedyQGlj42PqIuZt8Q/u3pjkbf17 LtAHsMRQoHKhQFSRekKEnC0PfR1O8h9yGpNUtdWXtuCeeG+hH24xHbMNyU9tY3gQWx0= X-Gm-Gg: ATEYQzxQJvnZvgJNkd8qkyaPzBg081EdwBaNG1cxs7YwB75n3mu3SO1kHa08WCiMuTn 9uzag+LDyonBGzJ1GEE1VW6XTAkS710XeMz4Kbwa20C7MP3+1LtWHMS2NtC6K17tElin6bLL6eG L3ET7LUmewB7h78pBZd6jcCQaLNhaQS0r3k2eIDnen7i27AKtXzERCrQJiCBfXSLiEh8bQQM2bq uXcSczZYAuJ1CR/EoTIPOemvbjK3kOnQ9rsb2xgMcW3+Y2q4op1u6iq5EFipnSU+kh25i76cb9K ElCDw6ktJKu1aG59cqFlRV9bZ1ObE/HV3HUlYxX5O4EibTipnfAihlPUM/+Eh+EqPEsyq8YPWyh MXb/HqE7+nVCw527vahOq++4dfWtihzDUVQzf03cR2Wbvr2HiyBN/YmoYV3YERbTs+bZoIQLtvk yVGkeFC+T6AuWgCa55jXycSQ== X-Received: by 2002:a05:6214:8110:b0:89a:250:767d with SMTP id 6a1803df08f44-89c85a99c60mr40131246d6.55.1774016679860; Fri, 20 Mar 2026 07:24:39 -0700 (PDT) Received: from localhost ([2603:7000:c00:3a00:365a:60ff:fe62:ff29]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-89c85233ea6sm20900116d6.11.2026.03.20.07.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Mar 2026 07:24:39 -0700 (PDT) Date: Fri, 20 Mar 2026 10:24:38 -0400 From: Johannes Weiner To: Alexandre Ghiti Cc: Andrew Morton , Chris Li , Kairui Song , Kemeng Shi , Nhat Pham , Baoquan He , Barry Song , kernel-team@meta.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/swap: fix swap cache memcg accounting Message-ID: References: <20260320050601.1833108-1-alex@ghiti.fr> 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: <20260320050601.1833108-1-alex@ghiti.fr> On Fri, Mar 20, 2026 at 06:05:59AM +0100, Alexandre Ghiti wrote: > The swap readahead path was recently refactored and while doing this, > the order between the charging of the folio in the memcg and the addition > of the folio in the swap cache was inverted. > > Since the accounting of the folio is done while adding the folio to the > swap cache and the folio is not charged in the memcg yet, the accounting > is then done at the node level, which is wrong. > > Fix this by charging the folio in the memcg before adding it to the swap cache. > > Fixes: 2732acda82c9 ("mm, swap: use swap cache as the swap in synchronize layer") > Signed-off-by: Alexandre Ghiti Acked-by: Johannes Weiner