Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755831AbdLVEVa (ORCPT ); Thu, 21 Dec 2017 23:21:30 -0500 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:56875 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755152AbdLVEV3 (ORCPT ); Thu, 21 Dec 2017 23:21:29 -0500 X-Originating-IP: 50.39.166.153 Date: Thu, 21 Dec 2017 20:21:20 -0800 From: Josh Triplett To: Matthew Wilcox Cc: Ross Zwisler , linux-kernel@vger.kernel.org, Dave Hansen , linux-mm@kvack.org, Matthew Wilcox Subject: Re: [PATCH 2/2] Introduce __cond_lock_err Message-ID: <20171222042120.GA18036@localhost> References: <20171219165823.24243-1-willy@infradead.org> <20171219165823.24243-2-willy@infradead.org> <20171221214810.GC9087@linux.intel.com> <20171222011000.GB23624@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171222011000.GB23624@bombadil.infradead.org> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1334 Lines: 31 On Thu, Dec 21, 2017 at 05:10:00PM -0800, Matthew Wilcox wrote: > On Thu, Dec 21, 2017 at 02:48:10PM -0700, Ross Zwisler wrote: > > > +++ b/include/linux/compiler_types.h > > > @@ -16,6 +16,7 @@ > > > # define __acquire(x) __context__(x,1) > > > # define __release(x) __context__(x,-1) > > > # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0) > > > +# define __cond_lock_err(x,c) ((c) ? 1 : ({ __acquire(x); 0; })) > > ^ > > I think we actually want this to return c here ^ > > > > The old code saved off the actual return value from __follow_pte_pmd() (say, > > -EINVAL) in 'res', and that was what was returned on error from both > > follow_pte_pmd() and follow_pte(). The value of 1 returned by __cond_lock() > > was just discarded (after we cast it to void for some reason). > > > > With this new code we actually return the value from __cond_lock_err(), which > > means that instead of returning -EINVAL, we'll return 1 on error. > > Yes, but this define is only #if __CHECKER__, so it doesn't matter what we > return as this code will never run. It does matter slightly, as Sparse does some (very limited) value-based analyses. Let's future-proof it. > That said, if sparse supports the GNU syntax of ?: then I have no > objection to doing that. Sparse does support that syntax. - Josh Triplett