From patchwork Tue Jan 2 17:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kairui Song X-Patchwork-Id: 13509229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4DB4C47073 for ; Tue, 2 Jan 2024 17:54:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B8DF6B0147; Tue, 2 Jan 2024 12:54:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 468D36B0149; Tue, 2 Jan 2024 12:54:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E4D76B014A; Tue, 2 Jan 2024 12:54:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1BED66B0147 for ; Tue, 2 Jan 2024 12:54:10 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id E0002A167E for ; Tue, 2 Jan 2024 17:54:09 +0000 (UTC) X-FDA: 81635119818.04.E80265B Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by imf02.hostedemail.com (Postfix) with ESMTP id 0568E8001A for ; Tue, 2 Jan 2024 17:54:07 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hqcqjNaU; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704218048; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HKSeSe6aIz/giM2hLWohMCNrft/gPTDUxVx5SpP3Eg8=; b=dBmBpDT18TOigpxqqf+LHYlEqkCfKWqU5mIwErBuhN1ptinB62anMBpQDT+lM5KB9Gu01G 3/0U6HFsLF+fv8oeCPEP1UVvapFHpVEo/OWVdK/m6JBk3dpsuvPfykVmxVbUEEDiU31U+K OPVbPbN/dUBq3j1esEvRyEogXbiSORc= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=hqcqjNaU; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of ryncsn@gmail.com designates 209.85.214.173 as permitted sender) smtp.mailfrom=ryncsn@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704218048; a=rsa-sha256; cv=none; b=UR9+DEyxzvrNILdrRlsZL87G0vWyLuvmbJNxfWZ/mrX/x1dc8WxB216ZlsAZbFHEjkJfwq AmSri0pLAXBP3++ty3jllcShNIkecEVuBC6DgpIjr44uYjZoyZ2Wdtxq8kz98hqfXft0qn aobeUjI4NC8irAImp7Gt+y8yyCzfLBE= Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1d3e84fded7so46826675ad.1 for ; Tue, 02 Jan 2024 09:54:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704218046; x=1704822846; darn=kvack.org; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=HKSeSe6aIz/giM2hLWohMCNrft/gPTDUxVx5SpP3Eg8=; b=hqcqjNaUTTrjGYv7ym3xuEooVS18Cirv6hXInfviuC5pSGfje8/BRmXP9DHIxL2f81 blONYiJYRGBtjHpTYRfH+HJbopkPo0UU7zaZg2zfUNjBAE8O+wpVpya7kNarz7CnqWjC aiBXKeICYmBlauybu9S7QjxH7tYzrCoe8VEyCT893sLc1QBoP+/3tRZvtpZCJM2mjLyH pGKN+QP7gyxxRUqZ3+v4HKsmUNZYMcYaqyHOeCd7IJMHfilX/RCc+UZjbTFtUOjdSILM FBLGp7t2UYtPBWB49hj4TWbvyU++FhwBJHmwZshZE8g83FHVvm3jLaiAZvcKwSKUlHkA PchA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704218046; x=1704822846; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=HKSeSe6aIz/giM2hLWohMCNrft/gPTDUxVx5SpP3Eg8=; b=eZ1laakK9L2nn9/HD1iS74S9abMBCzZ3wOFosP+pXp7lcmxDHBd1vFxoJAKAQnhHJD +wE/KT2/tOwRfY97BvBLfR7l5Ze4MCayYT1ixRhEuH9DLgSHvu8VK5ff/FUK81DZOpB1 ++TK3V3sn4nvT43n/wuEwaXJrMN3lshJNeZZSTqHwKdNcpHgwhsoPSQJyrn/XdSt16Oq Xw4TEAdGLJK4zS8OXZigtOJfG1NmYiqlnMF4KwViLFz8OQSgs3Z33UrI2HczHFVOjw8e EYl8B8EYPYhY4gantnbfvryYVbJd7uoYYs4JWkL/xKpiHrvxnNZuYsnG7iEatrSmdyXS YYtg== X-Gm-Message-State: AOJu0YxNo3E9oKi1JNAa3WM8LSaCWts1CqKSOjppY0n8tJ+nck1NaK/q vTQ13FiRETSdZLsCeGRjqM+kvcpXO13MQ6dP X-Google-Smtp-Source: AGHT+IGjD60IJ5O934G0uk9U2RzbZjBO7ugPyT2rW4oxx9bLV6dvHfHyD2MlY2xhFWamcsU7Iv7RfQ== X-Received: by 2002:a17:903:1251:b0:1d3:529a:83b6 with SMTP id u17-20020a170903125100b001d3529a83b6mr8433403plh.17.1704218046394; Tue, 02 Jan 2024 09:54:06 -0800 (PST) Received: from KASONG-MB2.tencent.com ([115.171.41.9]) by smtp.gmail.com with ESMTPSA id be10-20020a170902aa0a00b001d3c3d486bfsm22151969plb.163.2024.01.02.09.54.03 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 02 Jan 2024 09:54:05 -0800 (PST) From: Kairui Song To: linux-mm@kvack.org Cc: Andrew Morton , Chris Li , "Huang, Ying" , Hugh Dickins , Johannes Weiner , Matthew Wilcox , Michal Hocko , Yosry Ahmed , David Hildenbrand , linux-kernel@vger.kernel.org, Kairui Song Subject: [PATCH v2 4/9] mm/swap: always account swapped in page into current memcg Date: Wed, 3 Jan 2024 01:53:33 +0800 Message-ID: <20240102175338.62012-5-ryncsn@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240102175338.62012-1-ryncsn@gmail.com> References: <20240102175338.62012-1-ryncsn@gmail.com> Reply-To: Kairui Song MIME-Version: 1.0 X-Rspamd-Queue-Id: 0568E8001A X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: gwxbtkj71yw487iepxc1otrswiag3y5k X-HE-Tag: 1704218047-546649 X-HE-Meta: U2FsdGVkX18wjCq6hi4f1tRI6ONCnUy75vItiZsNwqgdbzyTw0I41v9nyf/xtrNt4MlrPOp9qNh1fxRpQyrAuF7FCrm7RhKuB+EL1wZN6pA48U9EpjZ4ZRInrnwYXxYX6JwLfOMmj3Lt/1p+QRBylj+sFTIjyqYJrqQp2mJS4h22H/QB8h1Wcv87QOQeG3CmSVv1G4sauizRCZU4nH9TTXNDUMVpJ6emjGbL32i+ZVUUzipajDlmjyjrQPrJWhMKdh0LTXWf10jmoC4Q5yqAGpNSz6OFZdSlGkRCNT2SXmJZeAlSHWts8LT2HeA44vDFQ8h2xprVDawse1wAvuTHvmBs6/tNeZHGHIbcr3a0xTlKPvvi2742/7r5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cSA0ei7Dx1QfSEsDar5slxyvcWLta9YYoOKfvQJvUlG7n4iXQ4MYoXQ32kKB03iKxsODTth0zc/clorEtYflCKFHULQJnMiecuACaP39pDvApqwVNcT4Fz/QF8/B5Ln791SD8lvlPzXgBz3MTqwk0Dsfc8PcbUFZGnKlI5DTU7JjmMc2 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: List-Subscribe: List-Unsubscribe: From: Kairui Song Currently, mem_cgroup_swapin_charge_folio is always called with mm argument as NULL, except in swapin_direct. swapin_direct is used when swapin should skip readahead and swapcache (SWP_SYNCHRONOUS_IO). Other caller paths of mem_cgroup_swapin_charge_folio are for swapin that should not skip readahead and cache. This could cause swapin charging to behave differently depending on swap device. This currently didn't happen because the only call path of swapin_direct is the direct anon page fault path, where mm equals to current->mm, but will no longer be true if swapin_direct is shared and have other callers (eg, swapoff). So make swapin_direct also passes NULL for mm, no feature change. Signed-off-by: Kairui Song --- mm/swap_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/swap_state.c b/mm/swap_state.c index 6130de8d5226..d39c5369da21 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c @@ -881,7 +881,7 @@ struct folio *swapin_direct(swp_entry_t entry, gfp_t gfp_mask, folio = vma_alloc_folio(GFP_HIGHUSER_MOVABLE, 0, vma, vmf->address, false); if (folio) { - if (mem_cgroup_swapin_charge_folio(folio, vma->vm_mm, + if (mem_cgroup_swapin_charge_folio(folio, NULL, GFP_KERNEL, entry)) { folio_put(folio); return NULL;