All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joel Fernandes <joelagnelf@nvidia.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Cc: Davidlohr Bueso <dave@stgolabs.net>,
	"Paul E. McKenney" <paulmck@kernel.org>,
	Josh Triplett <josh@joshtriplett.org>,
	Frederic Weisbecker <frederic@kernel.org>,
	Neeraj Upadhyay <neeraj.upadhyay@kernel.org>,
	Boqun Feng <boqun@kernel.org>,
	Uladzislau Rezki <urezki@gmail.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Lai Jiangshan <jiangshanlai@gmail.com>,
	Zqiang <qiang.zhang@linux.dev>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	rcu@vger.kernel.org
Subject: Re: [PATCH] rcuscale: Constify struct rcu_scale_ops
Date: Sun, 8 Nov 2026 18:06:23 -0500	[thread overview]
Message-ID: <20261108230623.GA3148953@joelbox> (raw)
In-Reply-To: <3f546f8e102ef271e7d5ac6d8b6a1f44d0fb20cb.1794085327.git.christophe.jaillet@wanadoo.fr>

On Sat, Nov 07, 2026 at 10:02:25PM +0100, Christophe JAILLET wrote:
> 'struct rcu_scale_ops' is not modified in this driver.
> 
> Constifying these structures moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>    text	   data	    bss	    dec	    hex	filename
>   45585	  24946	   2816	  73347	  11e83	kernel/rcu/rcuscale.o
> 
> After:
> =====
>    text	   data	    bss	    dec	    hex	filename
>   46545	  23986	   2816	  73347	  11e83	kernel/rcu/rcuscale.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.

rcuscale is a test kernel module, is it worth adding boilerplate for
non-production code sighting security reasons?

Do you mind runtime testing it too if you still feel we should do it (and
provide reasons why)?

thanks,

Joel Fernandes


> ---
>  kernel/rcu/rcuscale.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/rcu/rcuscale.c b/kernel/rcu/rcuscale.c
> index 1097ec15879c..522f7bc2e693 100644
> --- a/kernel/rcu/rcuscale.c
> +++ b/kernel/rcu/rcuscale.c
> @@ -159,7 +159,7 @@ struct rcu_scale_ops {
>  	const char *name;
>  };
>  
> -static struct rcu_scale_ops *cur_ops;
> +static const struct rcu_scale_ops *cur_ops;
>  
>  /*
>   * Definitions for rcu scalability testing.
> @@ -185,7 +185,7 @@ static void rcu_sync_scale_init(void)
>  {
>  }
>  
> -static struct rcu_scale_ops rcu_ops = {
> +static const struct rcu_scale_ops rcu_ops = {
>  	.ptype		= RCU_FLAVOR,
>  	.init		= rcu_sync_scale_init,
>  	.readlock	= rcu_scale_read_lock,
> @@ -247,7 +247,7 @@ static void srcu_scale_synchronize_expedited(void)
>  	synchronize_srcu_expedited(srcu_ctlp);
>  }
>  
> -static struct rcu_scale_ops srcu_ops = {
> +static const struct rcu_scale_ops srcu_ops = {
>  	.ptype		= SRCU_FLAVOR,
>  	.init		= rcu_sync_scale_init,
>  	.readlock	= srcu_scale_read_lock,
> @@ -276,7 +276,7 @@ static void srcu_sync_scale_cleanup(void)
>  	cleanup_srcu_struct(srcu_ctlp);
>  }
>  
> -static struct rcu_scale_ops srcud_ops = {
> +static const struct rcu_scale_ops srcud_ops = {
>  	.ptype		= SRCU_FLAVOR,
>  	.init		= srcu_sync_scale_init,
>  	.cleanup	= srcu_sync_scale_cleanup,
> @@ -313,7 +313,7 @@ static void rcu_tasks_scale_stats(void)
>  	rcu_tasks_torture_stats_print(scale_type, SCALE_FLAG);
>  }
>  
> -static struct rcu_scale_ops tasks_ops = {
> +static const struct rcu_scale_ops tasks_ops = {
>  	.ptype		= RCU_TASKS_FLAVOR,
>  	.init		= rcu_sync_scale_init,
>  	.readlock	= tasks_scale_read_lock,
> @@ -357,7 +357,7 @@ static void rcu_tasks_rude_scale_stats(void)
>  	rcu_tasks_rude_torture_stats_print(scale_type, SCALE_FLAG);
>  }
>  
> -static struct rcu_scale_ops tasks_rude_ops = {
> +static const struct rcu_scale_ops tasks_rude_ops = {
>  	.ptype		= RCU_TASKS_RUDE_FLAVOR,
>  	.init		= rcu_sync_scale_init,
>  	.readlock	= tasks_rude_scale_read_lock,
> @@ -396,7 +396,7 @@ static void tasks_trace_scale_read_unlock(int idx)
>  	rcu_read_unlock_trace();
>  }
>  
> -static struct rcu_scale_ops tasks_tracing_ops = {
> +static const struct rcu_scale_ops tasks_tracing_ops = {
>  	.ptype		= RCU_TASKS_FLAVOR,
>  	.init		= rcu_sync_scale_init,
>  	.readlock	= tasks_trace_scale_read_lock,
> @@ -693,7 +693,7 @@ rcu_scale_writer(void *arg)
>  }
>  
>  static void
> -rcu_scale_print_module_parms(struct rcu_scale_ops *cur_ops, const char *tag)
> +rcu_scale_print_module_parms(const struct rcu_scale_ops *cur_ops, const char *tag)
>  {
>  	pr_alert("%s" SCALE_FLAG
>  		 "--- %s: gp_async=%d gp_async_max=%d gp_exp=%d holdoff=%d minruntime=%d nreaders=%d nwriters=%d nexp=%d exp_interval=%d writer_holdoff=%d writer_holdoff_jiffies=%d verbose=%d shutdown_secs=%d\n",
> @@ -1109,7 +1109,7 @@ rcu_scale_init(void)
>  	int firsterr = 0;
>  	long i;
>  	long j;
> -	static struct rcu_scale_ops *scale_ops[] = {
> +	static const struct rcu_scale_ops *scale_ops[] = {
>  		&rcu_ops, &srcu_ops, &srcud_ops, TASKS_OPS TASKS_RUDE_OPS TASKS_TRACING_OPS
>  	};
>  
> -- 
> 2.56.0
> 

  parent reply	other threads:[~2026-11-08 23:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 21:02 [PATCH] rcuscale: Constify struct rcu_scale_ops Christophe JAILLET
2026-11-07 23:25 ` Bradley Morgan
2026-11-08 20:21   ` Christophe JAILLET
2026-11-08 23:06 ` Joel Fernandes [this message]
2026-11-09 17:32   ` Christophe JAILLET
2026-11-09 18:44     ` Paul E. McKenney
2026-11-10  5:06       ` Dan Carpenter
2026-11-10 18:34         ` Paul E. McKenney
2026-11-10 19:01           ` Bradley Morgan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261108230623.GA3148953@joelbox \
    --to=joelagnelf@nvidia.com \
    --cc=boqun@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=dave@stgolabs.net \
    --cc=frederic@kernel.org \
    --cc=jiangshanlai@gmail.com \
    --cc=josh@joshtriplett.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=neeraj.upadhyay@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=qiang.zhang@linux.dev \
    --cc=rcu@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=urezki@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.