From mboxrd@z Thu Jan 1 00:00:00 1970 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 5044DC433F5 for ; Thu, 20 Jan 2022 02:10:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D883E6B00CD; Wed, 19 Jan 2022 21:10:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D37CC6B00CE; Wed, 19 Jan 2022 21:10:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C26376B00CF; Wed, 19 Jan 2022 21:10:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0137.hostedemail.com [216.40.44.137]) by kanga.kvack.org (Postfix) with ESMTP id B22476B00CD for ; Wed, 19 Jan 2022 21:10:08 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 73DE286338 for ; Thu, 20 Jan 2022 02:10:08 +0000 (UTC) X-FDA: 79049035296.07.93F7DAC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id 0548E140003 for ; Thu, 20 Jan 2022 02:10:07 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7D6D1615E0; Thu, 20 Jan 2022 02:10:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9623DC340E4; Thu, 20 Jan 2022 02:10:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642644606; bh=H0CEFoSISCPFCDRFnMeFFAH/fy/VQv/ddBxTwfNzOPM=; h=Date:From:To:Subject:In-Reply-To:From; b=1SKMbPS2it3P40OtYmkm163JY0QvN0SJgE/Bb/Pe5eBEndUmQBlMKmVSQGjRGTyQ/ c+cdNRbAl5R8WT+6Wno+46sX/TcxZdYveoYrAdykHpxAJ35fiH6lYQw6J/1jbZaBJD s+DAQ8S9NYZg6++q97NDYPThhS6wJsXvdZqp5gO8= Date: Wed, 19 Jan 2022 18:10:06 -0800 From: Andrew Morton To: akpm@linux-foundation.org, bsingharora@gmail.com, hannes@cmpxchg.org, linux-mm@kvack.org, mingo@kernel.org, mm-commits@vger.kernel.org, peterz@infradead.org, torvalds@linux-foundation.org, yang.yang29@zte.com.cn, zealci@zte.com.cn Subject: [patch 45/55] delayacct: fix incomplete disable operation when switch enable to disable Message-ID: <20220120021006.cVLJPygAt%akpm@linux-foundation.org> In-Reply-To: <20220119180714.9e187ce100e4510de3cd9f7d@linux-foundation.org> User-Agent: s-nail v14.8.16 X-Rspamd-Queue-Id: 0548E140003 X-Stat-Signature: d3jgthhmba35k8m7rs1hboxyt974gfte Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=1SKMbPS2; dmarc=none; spf=pass (imf23.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Rspamd-Server: rspam03 X-HE-Tag: 1642644607-881265 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: From: Yang Yang Subject: delayacct: fix incomplete disable operation when switch enable to disable When a task is created after delayacct is enabled, kernel will do all the delay accountings for that task. The problems is if user disables delayacct by set /proc/sys/kernel/task_delayacct to zero, only blkio delay accounting is disabled. Now disable all the kinds of delay accountings when /proc/sys/kernel/task_delayacct sets to zero. Link: https://lkml.kernel.org/r/20211123140342.32962-1-ran.xiaokai@zte.com.cn Signed-off-by: Yang Yang Reported-by: Zeal Robot Cc: Balbir Singh Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Johannes Weiner Signed-off-by: Andrew Morton --- include/linux/delayacct.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/include/linux/delayacct.h~delayacct-fix-incomplete-disable-operation-when-switch-enable-to-disable +++ a/include/linux/delayacct.h @@ -131,36 +131,54 @@ static inline __u64 delayacct_blkio_tick static inline void delayacct_freepages_start(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_freepages_start(); } static inline void delayacct_freepages_end(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_freepages_end(); } static inline void delayacct_thrashing_start(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_thrashing_start(); } static inline void delayacct_thrashing_end(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_thrashing_end(); } static inline void delayacct_swapin_start(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_swapin_start(); } static inline void delayacct_swapin_end(void) { + if (!static_branch_unlikely(&delayacct_key)) + return; + if (current->delays) __delayacct_swapin_end(); } _