From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 166393112D0 for ; Wed, 10 Dec 2025 17:03:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765386215; cv=none; b=jOIJAaRBCg2OZZhNhTIgfSGKsidqX4ExvsxtQkN1EnvcHB0krlVeLiZleATrjHbur/DDoVLfvoPk6on/D8+H07XDCmcxHmzgpy/QXD7Z95n7ugGdoajPaFv5xfniAkH8Uu/viC+ElSQv9KYLUTfD5chMcMuvPot6NTqdd9Omw74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765386215; c=relaxed/simple; bh=RPxTcChdPb/JzQFaQmLxH7GtLRT9b+9D/1EX5YgYVrE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Qm6fHmSQYrD/MCxwj92lWBMR0rKLV9KvMQaxkRUokoxe2BxlihxQMc4W1w0UJQf4UKHC6LsmWrgHx23mhXi4GiIAya9hRrmldgRGgJanXi8gb1rly0TqXIiWWTl3u00xNEB87qlVI2ljbHpO4HPVk7kSBDxlfseP0apufLbX0Ls= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=jRvxOD4Q; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="jRvxOD4Q" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=6EfFv7qRrlQpdRGEwaXOMHx/cTVvWrCO6c7a2QMAqNk=; b=jRvxOD4QOY5jPgNvOMUkXZ9qUi gYwqdm0y6aVJ4M0xloGDWv7RV16e+875Wug945aTkk2zWPzklJx/UaO1dtoCqn8evVlrE4H0dNjP/ Sxb1o0z2sRk7E2cVuPg5MqIKKRM9eL6vR0mtKWfQllAiTkAZ5678eCuGb36hV59loxgNStnyFlnRd s2UQN5vrh3T/Lh24CndtdUXfSykK4d6/apIn9k4Pxh3YLT+P6TdDRMthjL7WOgtaKc8eqGOQdlp/A rFBnk1Si8HZN0yCk8/42uuppn+7QOtQSsXbCxuNSL9rLgdZG4oP1OjM6J0axhYeE+0MSLisrATfBu Hs8YDA1g==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vTNae-0000000D754-2kel; Wed, 10 Dec 2025 17:03:00 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id BB659300566; Wed, 10 Dec 2025 18:02:59 +0100 (CET) Date: Wed, 10 Dec 2025 18:02:59 +0100 From: Peter Zijlstra To: Tim Chen Cc: Ingo Molnar , K Prateek Nayak , "Gautham R . Shenoy" , Vincent Guittot , Chen Yu , Juri Lelli , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , Madadi Vineeth Reddy , Hillf Danton , Shrikanth Hegde , Jianyong Wu , Yangyu Chen , Tingyin Duan , Vern Hao , Vern Hao , Len Brown , Aubrey Li , Zhao Liu , Chen Yu , Adam Li , Aaron Lu , Tim Chen , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 20/23] sched/cache: Add user control to adjust the parameters of cache-aware scheduling Message-ID: <20251210170259.GZ3707891@noisy.programming.kicks-ass.net> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Dec 03, 2025 at 03:07:39PM -0800, Tim Chen wrote: > diff --git a/include/linux/sched.h b/include/linux/sched.h > index 466ba8b7398c..95bf080bbbf0 100644 > --- a/include/linux/sched.h > +++ b/include/linux/sched.h > @@ -2436,9 +2436,11 @@ extern void migrate_enable(void); > DEFINE_LOCK_GUARD_0(migrate, migrate_disable(), migrate_enable()) > > #ifdef CONFIG_SCHED_CACHE > +DECLARE_STATIC_KEY_FALSE(sched_cache_on); > + > static inline bool sched_cache_enabled(void) > { > - return false; > + return static_branch_unlikely(&sched_cache_on); > } > #endif > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > index 02e16b70a790..cde324672103 100644 > --- a/kernel/sched/debug.c > +++ b/kernel/sched/debug.c > @@ -169,6 +169,53 @@ static const struct file_operations sched_feat_fops = { > .release = single_release, > }; > > +#ifdef CONFIG_SCHED_CACHE > +#define SCHED_CACHE_CREATE_CONTROL(name, max) \ > +static ssize_t sched_cache_write_##name(struct file *filp, \ > + const char __user *ubuf, \ > + size_t cnt, loff_t *ppos) \ > +{ \ > + char buf[16]; \ > + unsigned int val; \ > + if (cnt > 15) \ > + cnt = 15; \ > + if (copy_from_user(&buf, ubuf, cnt)) \ > + return -EFAULT; \ > + buf[cnt] = '\0'; \ > + if (kstrtouint(buf, 10, &val)) \ > + return -EINVAL; \ > + if (val > (max)) \ > + return -EINVAL; \ > + llc_##name = val; \ > + if (!strcmp(#name, "enabled")) \ > + sched_cache_set(false); \ Oh gawd :-( Please just write out all the various write methods and use kstrtoul_from_user() and kstrtobool_from_user() where applicable. > + *ppos += cnt; \ > + return cnt; \ > +} \ > +static int sched_cache_show_##name(struct seq_file *m, void *v) \ > +{ \ > + seq_printf(m, "%d\n", llc_##name); \ > + return 0; \ > +} \ > +static int sched_cache_open_##name(struct inode *inode, \ > + struct file *filp) \ > +{ \ > + return single_open(filp, sched_cache_show_##name, NULL); \ > +} \ > +static const struct file_operations sched_cache_fops_##name = { \ > + .open = sched_cache_open_##name, \ > + .write = sched_cache_write_##name, \ > + .read = seq_read, \ > + .llseek = seq_lseek, \ > + .release = single_release, \ > +} > + > +SCHED_CACHE_CREATE_CONTROL(overload_pct, 100); > +SCHED_CACHE_CREATE_CONTROL(imb_pct, 100); > +SCHED_CACHE_CREATE_CONTROL(aggr_tolerance, 100); > +SCHED_CACHE_CREATE_CONTROL(enabled, 1);