From patchwork Tue Jul 30 12:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13747379 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 B1B5DC3DA49 for ; Tue, 30 Jul 2024 12:54:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 119696B0089; Tue, 30 Jul 2024 08:54:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0C8B96B008A; Tue, 30 Jul 2024 08:54:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E85086B008C; Tue, 30 Jul 2024 08:54:13 -0400 (EDT) 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 CB6216B0089 for ; Tue, 30 Jul 2024 08:54:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 48A2316015F for ; Tue, 30 Jul 2024 12:54:13 +0000 (UTC) X-FDA: 82396411986.02.DB1F606 Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) by imf05.hostedemail.com (Postfix) with ESMTP id 74DD910001A for ; Tue, 30 Jul 2024 12:54:11 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VA8Xtxa3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.179 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1722344047; a=rsa-sha256; cv=none; b=V7IwB/zgGQuPf+oMy1W7romGKCqUCr3paQnthnPD6HSfD+9qa1SWpZ5JwMTXdlqT+2yg7K L6Ai1S4t0TiWl6s0kF2XgICnfGeyZNyShTNqfIZQiOY4xODVnQx3vpmccJSriK9iV3mOXN 3IeNUP6bLzGErqZjzc0hP162tzvhkeA= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=VA8Xtxa3; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf05.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.222.179 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1722344047; h=from:from:sender: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=KP/Cz3QVNU5uyUnKyaSLbXt0q/kOvLrAG+hU9UnZ/BE=; b=fIu5dyU25HleKh++UievtDvBd80QvjgRGWHszyqOL6IFUzeGVLeGOlG1G4nDaktsiaREi6 CQUQ8f9bbh1tIteIlYZI9gxa9GK2N90O2fa+U4iOAVquoN5fA76YLXETuI00V5/WtuPVnR Jlq/S+A4Zh6qQUNMKFnX4uOwIKXl+FY= Received: by mail-qk1-f179.google.com with SMTP id af79cd13be357-7a1d42da3e9so300776285a.1 for ; Tue, 30 Jul 2024 05:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722344050; x=1722948850; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=KP/Cz3QVNU5uyUnKyaSLbXt0q/kOvLrAG+hU9UnZ/BE=; b=VA8Xtxa3viJ0s8IdiHzPPgEKbxkpV+vJaOK5O861oEUYj+FYz75EYyoI89GOXx8f/2 iTlGpsI3Z/F9yRVmqmowZXvvdDq+EAD270na5G2w5zvQ0qWNqSjTtlwS6dH4cl6+3OA/ x/b7Ktv31Tr23qGipNj+1/MrAQuTQwfRRwlTy6cTDeBqxFzcbZQ9cW/n+cc68lzeoMfP 5ZiB4pXkDmwetcBV39mGdxPsOm41UZ+sFDU82SQjKalyRR3F2mJf50g0Tm/PVNxhPGuR sHZCoNh7CeGDdPBjUffTuVTHR1kC0UwA1HGB0zoso41VtEZBUr24nfKS6tRuPbsEYUDl SFbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722344050; x=1722948850; h=content-transfer-encoding:mime-version: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=KP/Cz3QVNU5uyUnKyaSLbXt0q/kOvLrAG+hU9UnZ/BE=; b=V7ZbeUJhMH1NH9D8o6gRG1kSUwczGDWrZnIRmPfixFukKVXLaKvVqSsBwZLwdqlodk Q0baXnuNA+yklC8ifwbxHabXTNfCkIe723autoIbxgWofe0lVX2kc5hD/FzVD7sh6nra OleJb4kccCsvI1Euz7i66NpAQw5SF/M3WqnpQ1E5Em7Cv3DlwBHy8OyJOIJwqK+E9iAk TUozezQdNhZKiS7JQ2QNA6aEqO+aL90N5XUZAtinoQdMMfzTxwXX4oC3/l5ss0VrI4T/ pOrjJg9lyuwBiANXcCnpsU3isWsH4d3/jWVNDD0QluRiDWgLwPuhsvSUrJJ82Abq++v6 YmLA== X-Forwarded-Encrypted: i=1; AJvYcCX7S9hKNgXSJ6BzEPQ8RhhxtxeuTivVbKA7ANOQMX+F1B54FFTCxz/LJlNL1nJP1RPUXyoRWQ0c0qLrcjW2aJ0H2xE= X-Gm-Message-State: AOJu0YxArOGPozzorzrMaXNsDzn2C4/mEEPej0carL8/Hmb/0I3zUKfI GcneE3ilKpwEKBMIQn5JGQadlfjxDxUwQIK2SwsSPmJJ15l+RmY7 X-Google-Smtp-Source: AGHT+IGKfomzFh7hnhpcESd3MD/dzvcJlg6cDEKXingUGcZg56zluFUVdo6AMVlaIlW4lTWHXPgxoA== X-Received: by 2002:a05:620a:24c3:b0:79e:fcb8:815c with SMTP id af79cd13be357-7a1e52cdbf2mr1496430585a.54.1722344050589; Tue, 30 Jul 2024 05:54:10 -0700 (PDT) Received: from localhost (fwdproxy-ash-009.fbsv.net. [2a03:2880:20ff:9::face:b00c]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a1d73ea990sm626878885a.55.2024.07.30.05.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jul 2024 05:54:09 -0700 (PDT) From: Usama Arif To: akpm@linux-foundation.org, linux-mm@kvack.org Cc: hannes@cmpxchg.org, riel@surriel.com, shakeel.butt@linux.dev, roman.gushchin@linux.dev, yuzhao@google.com, david@redhat.com, baohua@kernel.org, ryan.roberts@arm.com, rppt@kernel.org, willy@infradead.org, cerasuolodomenico@gmail.com, corbet@lwn.net, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, kernel-team@meta.com, Usama Arif Subject: [PATCH 1/6] Revert "memcg: remove mem_cgroup_uncharge_list()" Date: Tue, 30 Jul 2024 13:45:58 +0100 Message-ID: <20240730125346.1580150-2-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240730125346.1580150-1-usamaarif642@gmail.com> References: <20240730125346.1580150-1-usamaarif642@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 74DD910001A X-Rspamd-Server: rspam01 X-Stat-Signature: brz7juccu19qstgtiiqdn9bu66q11msd X-HE-Tag: 1722344051-574690 X-HE-Meta: U2FsdGVkX1+WTebNjB45rWkvYdGvNSZu1Uc3Yfg0K3heZLFJBpirYLts/ux5E594EmN9vV0UHi7GZwOwrx9NM0ySgyU37ge4wh3Cwp7lt6yx4VekzfWlWFgQ6LPm1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WcxOPjtly9bsMKSPcF3Ay44FUk9ieOJgfX3VTGwIXzmywpOxD0SOT8Uix678gs7x98sD9i97eCRJVgt4ADi4wpnH5zPGPBj2WSkF5Pqm2FqVan5/OqdpCq1SodpCpmIyiDL6a+sDJxyVJejmlqfnSgI/z/eTuYpoD+obhqsjN7BVmXcVofL1NczQ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000068, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: mem_cgroup_uncharge_list will be needed in a later patch for an optimization to free zapped tail pages when splitting isolated thp. Signed-off-by: Usama Arif --- include/linux/memcontrol.h | 12 ++++++++++++ mm/memcontrol.c | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 07eadf7ecbba..cbaf0ea1b217 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -713,6 +713,14 @@ static inline void mem_cgroup_uncharge(struct folio *folio) __mem_cgroup_uncharge(folio); } +void __mem_cgroup_uncharge_list(struct list_head *page_list); +static inline void mem_cgroup_uncharge_list(struct list_head *page_list) +{ + if (mem_cgroup_disabled()) + return; + __mem_cgroup_uncharge_list(page_list); +} + void __mem_cgroup_uncharge_folios(struct folio_batch *folios); static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios) { @@ -1203,6 +1211,10 @@ static inline void mem_cgroup_uncharge(struct folio *folio) { } +static inline void mem_cgroup_uncharge_list(struct list_head *page_list) +{ +} + static inline void mem_cgroup_uncharge_folios(struct folio_batch *folios) { } diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 9b3ef3a70833..f568b9594c2b 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4717,6 +4717,25 @@ void __mem_cgroup_uncharge(struct folio *folio) uncharge_batch(&ug); } +/** + * __mem_cgroup_uncharge_list - uncharge a list of page + * @page_list: list of pages to uncharge + * + * Uncharge a list of pages previously charged with + * __mem_cgroup_charge(). + */ +void __mem_cgroup_uncharge_list(struct list_head *page_list) +{ + struct uncharge_gather ug; + struct folio *folio; + + uncharge_gather_clear(&ug); + list_for_each_entry(folio, page_list, lru) + uncharge_folio(folio, &ug); + if (ug.memcg) + uncharge_batch(&ug); +} + void __mem_cgroup_uncharge_folios(struct folio_batch *folios) { struct uncharge_gather ug;