From patchwork Fri Feb 12 17:01:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12085689 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=-16.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 54C20C433E0 for ; Fri, 12 Feb 2021 17:02:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C13DE64E05 for ; Fri, 12 Feb 2021 17:02:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C13DE64E05 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bytedance.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4CBFA8D006E; Fri, 12 Feb 2021 12:02:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 47D6C8D0060; Fri, 12 Feb 2021 12:02:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36CC28D006E; Fri, 12 Feb 2021 12:02:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 20B518D0060 for ; Fri, 12 Feb 2021 12:02:18 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id D8F008248047 for ; Fri, 12 Feb 2021 17:02:17 +0000 (UTC) X-FDA: 77810233914.01.drop55_140c02a27622 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin01.hostedemail.com (Postfix) with ESMTP id B9D4310057A32 for ; Fri, 12 Feb 2021 17:02:17 +0000 (UTC) X-HE-Tag: drop55_140c02a27622 X-Filterd-Recvd-Size: 4173 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf29.hostedemail.com (Postfix) with ESMTP for ; Fri, 12 Feb 2021 17:02:17 +0000 (UTC) Received: by mail-pj1-f53.google.com with SMTP id z9so758596pjl.5 for ; Fri, 12 Feb 2021 09:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hdVPqrFgHTgC5mTllAq9fBNSua/ngygoblWbV1oigUI=; b=Wqq++mXdhn6HE2fF23Wh8h9AFqcynW3GPMQs21nMApsmcn9L4h6O8KtYPRjAUeNCDn iNMu2YDjYyY8JDBGuTJAEVoQcXdkJcwdAMiDMk/43qpb0yi2y/gjcH86jMmW4oRF16x3 L8UNDDz8q5XJPbV/D8jN4450QYrAUnCaJ5cUuSHsVoO/e/3r98A0TR3WAK0qaFp0ufcz 5FcU7+Yz6okzH9k+R28b7nmm6Z9f63wUb2h6VTNDmLX3s/VAfDqzX8JRwrHt08eJ5okY cIbjgV0hM5kJGL5B1Ttc4NuCgqtZIs5c37uIrW6rDWoTarmMsvNlMxDDAHHWfGQAiIkl 0GaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=hdVPqrFgHTgC5mTllAq9fBNSua/ngygoblWbV1oigUI=; b=eLhCGFCOa3yZWuKQ5DMKqmmIekYNy5FvVrLUroCD8f6HBbpayk67dTmcWsWDTdz491 DLd7HbwORMD62x41qw+gLOd9KYLF92eA3psoMR3FFdemz+UIJzd1fbcyqiTp2VmTOKvu aELt9j0nBIUZnEML4z99omsISgqahBt/WfUPjXU1OUOSO5qq96q5BFHPHtoHCC5L84ht Eip2kMa/7AVPw8jS1Krv9qp16rDyzPPH1v2GKQTTloeWI8PNWBRzSTS1ZFcCYVmFD/mx TtcFCnba95mapE89SsLjNEYaomYAts6VKgvhAtFhMLUgvkehvwfuhZYSCiOv6cRSP5Ul duGw== X-Gm-Message-State: AOAM530qk3d9M1z5YWVJErXe18qaVdqlRk/51p+edkBcx4GYit7HlREG C7tzMQb7kf3zDwAQ/ClqNN+2jg== X-Google-Smtp-Source: ABdhPJybZwdjimV2P5ym8dkQiRVRyC5DByFMgygAkBaUP5rkFW8O6XL/Sn6SVVsiqOEugp4e7rkVow== X-Received: by 2002:a17:90b:2312:: with SMTP id mt18mr3636553pjb.81.1613149336083; Fri, 12 Feb 2021 09:02:16 -0800 (PST) Received: from localhost.bytedance.net ([139.177.225.254]) by smtp.gmail.com with ESMTPSA id e21sm9317815pgv.74.2021.02.12.09.02.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Feb 2021 09:02:15 -0800 (PST) From: Muchun Song To: hannes@cmpxchg.org, mhocko@kernel.org, vdavydov.dev@gmail.com, akpm@linux-foundation.org Cc: cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Muchun Song Subject: [PATCH 1/4] mm: memcontrol: remove memcg check from memcg_oom_recover Date: Sat, 13 Feb 2021 01:01:56 +0800 Message-Id: <20210212170159.32153-1-songmuchun@bytedance.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122) MIME-Version: 1.0 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: The memcg_oom_recover() almost never do anything but the test (because oom_disabled is a rarely used) is just waste of cycles in some hot paths (e.g. kmem uncharge). And it is very small, so it is better to make it inline. Also, the parameter of memcg cannot be NULL, so removing the check can reduce useless check. Signed-off-by: Muchun Song --- mm/memcontrol.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 8c035846c7a4..7afca9677693 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1925,7 +1925,7 @@ static int memcg_oom_wake_function(wait_queue_entry_t *wait, return autoremove_wake_function(wait, mode, sync, arg); } -static void memcg_oom_recover(struct mem_cgroup *memcg) +static inline void memcg_oom_recover(struct mem_cgroup *memcg) { /* * For the following lockless ->under_oom test, the only required @@ -1935,7 +1935,7 @@ static void memcg_oom_recover(struct mem_cgroup *memcg) * achieved by invoking mem_cgroup_mark_under_oom() before * triggering notification. */ - if (memcg && memcg->under_oom) + if (memcg->under_oom) __wake_up(&memcg_oom_waitq, TASK_NORMAL, 0, memcg); }