From patchwork Mon Dec 7 14:22:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hui Su X-Patchwork-Id: 11956113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A44C4361B for ; Mon, 7 Dec 2020 14:22:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 692AB235F9 for ; Mon, 7 Dec 2020 14:22:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 692AB235F9 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=163.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8D8848D0003; Mon, 7 Dec 2020 09:22:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 862018D0001; Mon, 7 Dec 2020 09:22:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 72C168D0003; Mon, 7 Dec 2020 09:22:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0055.hostedemail.com [216.40.44.55]) by kanga.kvack.org (Postfix) with ESMTP id 58E268D0001 for ; Mon, 7 Dec 2020 09:22:37 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 1DE9B1EF1 for ; Mon, 7 Dec 2020 14:22:37 +0000 (UTC) X-FDA: 77566701954.25.smell91_0f001c4273df Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id E9AFE1804E3A1 for ; Mon, 7 Dec 2020 14:22:36 +0000 (UTC) X-HE-Tag: smell91_0f001c4273df X-Filterd-Recvd-Size: 3258 Received: from m12-14.163.com (m12-14.163.com [220.181.12.14]) by imf06.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 14:22:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=Date:From:Subject:Message-ID:MIME-Version; bh=3uk2L bhtc7beQcuFB/TC0ws6g0FxHPq8w1P2GqYnqaM=; b=lu29XvI8SSVKydg5pArXy IF+jH7YG4kkUn/HWrrY1WXAh/afpnR8I/vL5m34N6ONffljdeC0yZa09HEsQzyOL GwHjS2zG7fWbDouLcjGvTihqThe1eeJig3+yKb+TFY8i+68dyKeqfIFGAARo/JHs U1bIFU5je+N2xIXSK+Y7jk= Received: from localhost (unknown [223.104.66.117]) by smtp10 (Coremail) with SMTP id DsCowABnfo6MOs5fDyHjZg--.32833S2; Mon, 07 Dec 2020 22:22:05 +0800 (CST) Date: Mon, 7 Dec 2020 22:22:04 +0800 From: Hui Su To: akpm@linux-foundation.org, shakeelb@google.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: songmuchun@bytedance.com Subject: [PATCH] mm/page_alloc: simplify kmem cgroup charge/uncharge code Message-ID: <20201207142204.GA18516@rlk> MIME-Version: 1.0 Content-Disposition: inline X-CM-TRANSID: DsCowABnfo6MOs5fDyHjZg--.32833S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7trW3uFWfGF1rZr45WF47CFg_yoW8ArykpF 45JF1Iyw48X3WrAF42y3Wqk345ZwsYqFWrAa98Xw48Zw13Jw1Syr9rGFyxuFyfGrZ7A3y3 GrsxAas8Wan8AaUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07bsLvtUUUUU= X-Originating-IP: [223.104.66.117] X-CM-SenderInfo: xvkbvvri6rljoofrz/1tbiWQ3zX1WBttL-cQAAsG X-Bogosity: Ham, tests=bogofilter, spamicity=0.226388, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Since the commit 60cd4bcd6238 ("memcg: localize memcg_kmem_enabled() check"), we have supplied the api which users don't have to explicitly check memcg_kmem_enabled(). Signed-off-by: Hui Su Reviewed-by: Muchun Song --- mm/page_alloc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index eaa227a479e4..dc990a899ded 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1214,8 +1214,8 @@ static __always_inline bool free_pages_prepare(struct page *page, * Do not let hwpoison pages hit pcplists/buddy * Untie memcg state and reset page's owner */ - if (memcg_kmem_enabled() && PageKmemcg(page)) - __memcg_kmem_uncharge_page(page, order); + if (PageKmemcg(page)) + memcg_kmem_uncharge_page(page, order); reset_page_owner(page, order); return false; } @@ -1244,8 +1244,8 @@ static __always_inline bool free_pages_prepare(struct page *page, } if (PageMappingFlags(page)) page->mapping = NULL; - if (memcg_kmem_enabled() && PageKmemcg(page)) - __memcg_kmem_uncharge_page(page, order); + if (PageKmemcg(page)) + memcg_kmem_uncharge_page(page, order); if (check_free) bad += check_free_page(page); if (bad) @@ -4965,8 +4965,8 @@ __alloc_pages_nodemask(gfp_t gfp_mask, unsigned int order, int preferred_nid, page = __alloc_pages_slowpath(alloc_mask, order, &ac); out: - if (memcg_kmem_enabled() && (gfp_mask & __GFP_ACCOUNT) && page && - unlikely(__memcg_kmem_charge_page(page, gfp_mask, order) != 0)) { + if ((gfp_mask & __GFP_ACCOUNT) && page && + unlikely(memcg_kmem_charge_page(page, gfp_mask, order) != 0)) { __free_pages(page, order); page = NULL; }