From patchwork Mon Jul 26 16:53:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasily Averin X-Patchwork-Id: 12400189 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=-17.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 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 97418C4338F for ; Mon, 26 Jul 2021 16:53:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 028C360E08 for ; Mon, 26 Jul 2021 16:53:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 028C360E08 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 207228D0002; Mon, 26 Jul 2021 12:53:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 191648D0001; Mon, 26 Jul 2021 12:53:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 059108D0002; Mon, 26 Jul 2021 12:53:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0225.hostedemail.com [216.40.44.225]) by kanga.kvack.org (Postfix) with ESMTP id E0DD78D0001 for ; Mon, 26 Jul 2021 12:53:41 -0400 (EDT) Received: from smtpin33.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 89C3C1808F545 for ; Mon, 26 Jul 2021 16:53:41 +0000 (UTC) X-FDA: 78405335442.33.61D06E0 Received: from relay.sw.ru (relay.sw.ru [185.231.240.75]) by imf03.hostedemail.com (Postfix) with ESMTP id 0181130002D0 for ; Mon, 26 Jul 2021 16:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=Content-Type:MIME-Version:Date:Message-ID:Subject :From; bh=p/l/Qj5INqHXINcKY/nrenLT6M8MZaYS0obzKpoLW2A=; b=a8+z8C6hzM4rexpHmG6 4BApTO6gkg2j2EmkhoqjO6W1Ih6f8q0ba4BjL2d5wigrNGI1y8wPDgijzGMZ0zqQa4+9yQHeU+1bM FMk4BtIrgEhv14RPa/EdrJbjZdm1udMqbhzHsqOOHVh0uc8u1DXTEBAw7IbpvzLw/YFM1i40ZI8=; Received: from [10.93.0.56] by relay.sw.ru with esmtp (Exim 4.94.2) (envelope-from ) id 1m83rE-005IPH-OE; Mon, 26 Jul 2021 19:53:36 +0300 From: Vasily Averin Subject: [PATCH] memcg: replace in_interrupt() by !in_task() in active_memcg() To: Shakeel Butt , Johannes Weiner , Michal Hocko , Vladimir Davydov , Roman Gushchin , Andrew Morton Cc: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: Message-ID: Date: Mon, 26 Jul 2021 19:53:36 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0181130002D0 Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=virtuozzo.com header.s=relay header.b=a8+z8C6h; spf=pass (imf03.hostedemail.com: domain of vvs@virtuozzo.com designates 185.231.240.75 as permitted sender) smtp.mailfrom=vvs@virtuozzo.com; dmarc=pass (policy=quarantine) header.from=virtuozzo.com X-Stat-Signature: 4frqaryym67s5o93jxaw5q6adu7w9y6h X-HE-Tag: 1627318420-53477 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: set_active_memcg() uses in_interrupt() check to select proper storage for cgroup: pointer on task struct or per-cpu pointer. It isn't fully correct: obsoleted in_interrupt() includes tasks with disabled BH. It's better to use '!in_task()' instead. Link: https://lkml.org/lkml/2021/7/26/487 Fixes: 37d5985c003d ("mm: kmem: prepare remote memcg charging infra for interrupt contexts") Signed-off-by: Vasily Averin Reviewed-by: Shakeel Butt --- include/linux/sched/mm.h | 2 +- mm/memcontrol.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index e24b1fe348e3..9dd071f78dba 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -306,7 +306,7 @@ set_active_memcg(struct mem_cgroup *memcg) { struct mem_cgroup *old; - if (in_interrupt()) { + if (!in_task()) { old = this_cpu_read(int_active_memcg); this_cpu_write(int_active_memcg, memcg); } else { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index ae1f5d0cb581..3ebf792ef2c0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -905,7 +905,7 @@ EXPORT_SYMBOL(mem_cgroup_from_task); static __always_inline struct mem_cgroup *active_memcg(void) { - if (in_interrupt()) + if (!in_task()) return this_cpu_read(int_active_memcg); else return current->active_memcg;