[Linux-kernel-mentees] [PATCH] exit.c: Fix Sparse errors and warnings

Oleg Nesterov oleg at redhat.com
Thu Jan 30 11:33:41 UTC 2020


On 01/30, Christian Brauner wrote:
>
> On Thu, Jan 30, 2020 at 11:50:28AM +0530, madhuparnabhowmik10 at gmail.com wrote:
> > From: Madhuparna Bhowmik <madhuparnabhowmik10 at gmail.com>
> >
> > This patch fixes the following sparse error:
> > kernel/exit.c:627:25: error: incompatible types in comparison expression
> >
> > And the following warning:
> > kernel/exit.c:626:40: warning: incorrect type in assignment
> >
> > Signed-off-by: Madhuparna Bhowmik <madhuparnabhowmik10 at gmail.com>
>
> I think the previous version was already fine but hopefully
> RCU_INIT_POINTER() really saves some overhead. In any case:

It is not about overhead, RCU_INIT_POINTER() documents the fact that we
didn't make any changes to the new parent, we only need to change the
pointer.

And btw, I don't really understand the __rcu annotations. Say, according
to sparse this code is wrong:

	int __rcu *P;

	void func(int *p)
	{
		P = p;
	}

OK, although quite possibly it is fine.

However, this code

	int __rcu *P;

	void func(int __rcu *p)
	{
		*p = 10;
	       	P = p;
	}

is almost certainly wrong but sparse is happy, asn is the same.


> Acked-by: Christian Brauner <christian.brauner at ubuntu.com>

Acked-by: Oleg Nesterov <oleg at redhat.com>



More information about the Linux-kernel-mentees mailing list