Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp170012ybl; Thu, 23 Jan 2020 20:58:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxGML/rGeVwKNGe4H7QwEPidQsR5swdHrgXEhCIXLjBykP1Wtq9/7XjZBHcQgiwQ+yhV7Br X-Received: by 2002:a9d:76cb:: with SMTP id p11mr1451416otl.7.1579841891764; Thu, 23 Jan 2020 20:58:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579841891; cv=none; d=google.com; s=arc-20160816; b=UdUlsk7gLf/YTwsrrCfvSfmL8jNjeHmm/MJ4mhKFrsIusFCct2XEV5Qu1ZwM50zRRe Uj3LHDHGM6hIvtoVhiNK3yVRbd58bPEeXYPjhHpY/iHi2wUIqNL+lDwaZBmsG2PdNEht evUibSea5HLYcgEaM9pi/sZn7NmCNJLpi9/iYxqccEzQWcnjvy1QDWuB7Xs30+Td94XO riTjWm2j4p5jomIt7h8UnzqxGPoGZZIfQE21sUQnsUvbY4PyHVN4T22+EmZTdptJDLir SGKFfLqnVNwTdmTy2RdmLPFeTRdptrYPzMV3LSo/cnWqn/FKevxdlydceoHpXQ9GpSjw qiIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date:from:dkim-signature; bh=W5pF9JS7OfQogiQ+v1H3GtBwMtau9/tHuDv1Q9h5buA=; b=0ZBqfd/cvNGWUr1K3CQExwXHhVlOti72FWFkN9qHu4OHNEpMNHTCKaNOlx2AJms2LN NRjFxv5U2SPiUPVd+GuUg8lmanMHg5eWwKonbNQ5VoSUBtE5/NSxLVp9/UXxlGg0M92e IRLE5siDOVK8tqRkaYuwPKkdkW0YgYCbWZ+UH+e51SyCHEBM4/a/l748xc1I5Nvqz3/p xoADMaidLxtmWfv2yyVQKDXyEaUBB2f0npe0/0zFSc0PoFvfd309oWNRenvAxf8avtMg aatfV1cfpSB+rjPHDBY0ijW/aFoinmgdofPGbHJc+lX+QYPMnytVV1rRnB/D42UMEbS2 zGRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sg5itA96; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x186si1887229oig.209.2020.01.23.20.57.59; Thu, 23 Jan 2020 20:58:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Sg5itA96; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730499AbgAXE3G (ORCPT + 99 others); Thu, 23 Jan 2020 23:29:06 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:55805 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729760AbgAXE3G (ORCPT ); Thu, 23 Jan 2020 23:29:06 -0500 Received: by mail-pj1-f68.google.com with SMTP id d5so459938pjz.5; Thu, 23 Jan 2020 20:29:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=W5pF9JS7OfQogiQ+v1H3GtBwMtau9/tHuDv1Q9h5buA=; b=Sg5itA96fCucpWFLPztS45UrhdU//Yjb9e3vjuwavSuwIsEFNQVX2ZPToq0NWtjIIC HkRfgfgyS11flHWhXXEFQvCg6EbCVYgR2fPisPweEkJA8vBD155pupXWLhqDx3FaxlTO 9ScXQuVU+BYXGdJENQyKT5QGGLQ+y6rDcOd1OzPbCpt6oEHAFBRn8VTl+mfUrqTLxiM/ kc1c8wcYMrNIM+own+kkA6QzBGRgNf5ljnLWAUbvPjX2ui0tWZqMORkoORYY0Eyooxrt AbI4PxV5886ntusBBmpJyEsQy+HJaYyk9G8qHfEaqHXUUDnXmjGWc1gTQ0z5LW1uQniw khHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=W5pF9JS7OfQogiQ+v1H3GtBwMtau9/tHuDv1Q9h5buA=; b=dRiwex23Va2pMGvGUUo+PLaOwyZ/FTzcwxa6p5E3FhqsP6yQxONeLdX+aBzH5qPsxY r0FByZGy6yKtjTN1I6QvspyGZkQ+bonu1LsToRsKmMzzvnyN+MFVmqA6qlc+DFCgVNzR kmqKsDKZlCqat/nNz4sOlWgTYudruk5jSGo1Nsdo84oSp07OfXDyAGQfD/yZiIupIJws nkzK2ncxIad+Lqm2jImHJ9bPd+tzOTie2CV9RciJbE+24ziL8GPajz09nNi5B38Mh9Z0 6/DyUz9NHSNZihZ+kh0kQZuIvgUyasWed15v2F8ghDySNT5PeKEekyKpsrq5L9GL+uxE 8zLA== X-Gm-Message-State: APjAAAXAdtbij3LetUw7L+eRRUwULuH8XlnkHFUyjJAXRK8fuUYEZOzo XKD5J/aWoO+jNdHPaa1QYg== X-Received: by 2002:a17:90a:fa88:: with SMTP id cu8mr1112275pjb.141.1579840145559; Thu, 23 Jan 2020 20:29:05 -0800 (PST) Received: from madhuparna-HP-Notebook ([2402:3a80:1ee5:e37b:72:f3a9:f673:9aea]) by smtp.gmail.com with ESMTPSA id iq22sm4558521pjb.9.2020.01.23.20.28.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Jan 2020 20:29:04 -0800 (PST) From: Madhuparna Bhowmik X-Google-Original-From: Madhuparna Bhowmik Date: Fri, 24 Jan 2020 09:58:52 +0530 To: "Paul E. McKenney" Cc: madhuparnabhowmik10@gmail.com, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, ebiederm@xmission.com, christian.brauner@ubuntu.com, oleg@redhat.com, joel@joelfernandes.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, frextrite@gmail.com, rcu@vger.kernel.org Subject: Re: [PATCH] sched.h: Annotate sighand_struct with __rcu Message-ID: <20200124042852.GC23699@madhuparna-HP-Notebook> References: <20200123145305.10652-1-madhuparnabhowmik10@gmail.com> <20200123164108.GQ2935@paulmck-ThinkPad-P72> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200123164108.GQ2935@paulmck-ThinkPad-P72> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 23, 2020 at 08:41:08AM -0800, Paul E. McKenney wrote: > On Thu, Jan 23, 2020 at 08:23:05PM +0530, madhuparnabhowmik10@gmail.com wrote: > > From: Madhuparna Bhowmik > > > > This patch fixes the following sparse errors by annotating the > > sighand_struct with __rcu > > > > kernel/fork.c:1511:9: error: incompatible types in comparison expression > > kernel/exit.c:100:19: error: incompatible types in comparison expression > > kernel/signal.c:1370:27: error: incompatible types in comparison expression > > > > This fix introduces the following sparse error in signal.c due to > > checking the sighand pointer without rcu primitives: > > > > kernel/signal.c:1386:21: error: incompatible types in comparison expression > > > > This new sparse error is also addressed in this patch. > > > > Signed-off-by: Madhuparna Bhowmik > > --- > > include/linux/sched.h | 2 +- > > kernel/signal.c | 3 ++- > > 2 files changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/sched.h b/include/linux/sched.h > > index b511e178a89f..7a351360ad54 100644 > > --- a/include/linux/sched.h > > +++ b/include/linux/sched.h > > @@ -918,7 +918,7 @@ struct task_struct { > > > > /* Signal handlers: */ > > struct signal_struct *signal; > > - struct sighand_struct *sighand; > > + struct sighand_struct __rcu *sighand; > > sigset_t blocked; > > sigset_t real_blocked; > > /* Restored if set_restore_sigmask() was used: */ > > diff --git a/kernel/signal.c b/kernel/signal.c > > index bcd46f547db3..1272def37462 100644 > > --- a/kernel/signal.c > > +++ b/kernel/signal.c > > @@ -1383,7 +1383,8 @@ struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, > > * must see ->sighand == NULL. > > */ > > spin_lock_irqsave(&sighand->siglock, *flags); > > - if (likely(sighand == tsk->sighand)) > > + if (likely(sighand == rcu_dereference_protected(tsk->sighand, > > + lockdep_is_held(&sighand->siglock)))) > > Given that the return value is never dereferenced, you can use > rcu_access_pointer(), which may be used outside of an RCU read-side > critical section, and thus does not need the lockdep_is_held(). So this > change would save a line of code and would be a bit easier on the eyes. > Okay got it! I will send the updated patch soon. Thank you, Madhuparna > Thanx, Paul > > > break; > > spin_unlock_irqrestore(&sighand->siglock, *flags); > > } > > -- > > 2.17.1 > >