Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp7527720imu; Mon, 3 Dec 2018 14:31:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/UEZpzGQTahetVsCiupjYGag+6NKeusRu6l0TGLE1v67P5tAJHuML/7uhN2r6cw7QvDP349 X-Received: by 2002:a62:6a88:: with SMTP id f130mr17842948pfc.201.1543876312707; Mon, 03 Dec 2018 14:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543876312; cv=none; d=google.com; s=arc-20160816; b=SThLBJkEiDQEsssOARzJFkQN0be/srUseZhhtlSn0JhwtGBfPke0y+odhH++pRNeVK qDUjTm1kUgO51hX0liJBMTUlxMzrAyNGYfszNf2Oyhbzn73dGcp7pU7Fbh+PdxMyEFBU tNRIQarXT6DgrNifYC+9gmqMuqUlQpz/I8kNYFk9lKKZMwuY28ehbegyWaoOSgDUw234 fnYtpLiK5ue63BWvft4IAWLpJKS2lgQgQiGJp0Q3TjqCn2KQp9kYhFkdZShuoSYEpan1 Vgb2vpPdd9j3zzfhA5F21Ll6a8awWPgHe9GkhNfHNzOv/+77LoX9tzXhBogXTa4snElH SI1Q== 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:from:date:dkim-signature; bh=MiQ1Ug+Qk3yyAuP47luLctb2QOhjx4xuSb3MsM+ToFE=; b=V0Lzh9C2eEJRWqxxQbPs6ZJsNGrqt2md1IR/PRfAcs89HpqZDOi10AmC3NCbL5iSC5 3h/T3WDLXks3TRi6VTNq8G9z8wtnmrQfFc+UjXc3wipdAyTTDSRFk6XiCUvmHtuwiGZ3 N7xxRUH+oAnLNz/duPqTHzUMZtr7NIU9ZDK0DdZCeEorWLRFFJ3N9QYqQKMdECQKewKv hMstONKeRu3rIUBFCLmAPbSGmD2eZRXnhtmzpNMWTClJitiMJK4/Jsw6rVSIitdNUuwt 1G1m0hCbfXOfg4kzz9ahoDRGYzu/82nKa+gUQTFk/aRZkxEQ+GAdFoZKhiNNibHRRA4s qYhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XXvaeO+i; 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 bb4si14194357plb.322.2018.12.03.14.31.36; Mon, 03 Dec 2018 14:31:52 -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=XXvaeO+i; 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 S1726001AbeLCW3r (ORCPT + 99 others); Mon, 3 Dec 2018 17:29:47 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:45741 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725893AbeLCW3q (ORCPT ); Mon, 3 Dec 2018 17:29:46 -0500 Received: by mail-ed1-f66.google.com with SMTP id d39so12170862edb.12 for ; Mon, 03 Dec 2018 14:29:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=MiQ1Ug+Qk3yyAuP47luLctb2QOhjx4xuSb3MsM+ToFE=; b=XXvaeO+ir7ySgBrqdCk62rPv7sVvJGwGUx4+C0oK+0bGpq/8TYxwsJdyDWBwTcHWXX QKAFRBuvljwRnmypODwk6DhIN38xNRUEMc7sHGcvSxVZyol2Dig4BSS+sBgsPTyVWMJF QfLAGcgnQB16DdQhhi/L+KXYb1cltBGTTwIMByiKDB2JDYvITqgAciU3L8Bpwcq0G7V4 sEcfGQo+jAj9NPLrfwbiFjbgkGi5uUagR2Qep9y2GQRZXNd32oxNdtlQSbLFhjwh2MrR 6BD7MReIWm95g//HvN1dUCZ/zcZZcIRHeXn406PgZClrIkdSfNNV8hM9LFUdjbvhFSFa 0qyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=MiQ1Ug+Qk3yyAuP47luLctb2QOhjx4xuSb3MsM+ToFE=; b=aL8ILD1heOsehxRJfvYPKpRa7JnQL4Oj5OVs3B5fbGsV14osOUk9tEERv6DoOqXAYg occqHqtkT6kx/APW2Esh00A/asKtTzCHH7wbjvJ5KkciSetyxLylA9b3RraKnwJDJF9O bXmQS8xaaqvXawOTZxzaRHEhUARxTB9mbtUpHpMpTPh0ndvf3Vq3+wZzEmtkqm9NzxRo qYIQtYKrblz5dyXDKedBsIK1BIBJ++ia7baniJCEn1eD97lpVtYrjTIdV/PamAujHbsQ s3Oqn5GXw2vIVGyCWHSwJ1yoO/6A3Aud1wpR1nm2BJ8TIPPHUBAtOB5aZX60La8XdFPZ Cd/A== X-Gm-Message-State: AA+aEWaftUT9HR+fnlESUHjNxuOhRidG04XhkbpzTN/m7/VppoBbVOsa FonNsLDivklxq1L7VSW/QVo= X-Received: by 2002:a50:9ee3:: with SMTP id a90mr16085153edf.283.1543876185100; Mon, 03 Dec 2018 14:29:45 -0800 (PST) Received: from ltop.local ([2a02:a03f:40bc:4d00:6932:2c57:7da2:797e]) by smtp.gmail.com with ESMTPSA id v9sm4256850edl.3.2018.12.03.14.29.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 14:29:44 -0800 (PST) Date: Mon, 3 Dec 2018 23:29:43 +0100 From: Luc Van Oostenryck To: Todd Kjos Cc: tkjos@google.com, gregkh@linuxfoundation.org, arve@android.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, maco@google.com, joel@joelfernandes.org, kernel-team@android.com Subject: Re: [PATCH] binder: fix sparse warnings on locking context Message-ID: <20181203222942.zkvwdws5qmkhfuhw@ltop.local> References: <20181203202457.228972-1-tkjos@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181203202457.228972-1-tkjos@google.com> User-Agent: NeoMutt/20180622 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Dec 03, 2018 at 12:24:54PM -0800, Todd Kjos wrote: > Add __acquire()/__release() annnotations to fix warnings > in sparse context checking > > There is one case where the warning was due to a lack of > a "default:" case in a switch statement where a lock was > being released in each of the cases, so the default > case was added. > > Signed-off-by: Todd Kjos > --- > drivers/android/binder.c | 43 +++++++++++++++++++++++++++++++++- > drivers/android/binder_alloc.c | 1 + > 2 files changed, 43 insertions(+), 1 deletion(-) > > diff --git a/drivers/android/binder.c b/drivers/android/binder.c > index 9f1000d2a40c7..9f2059d24ae2d 100644 > --- a/drivers/android/binder.c > +++ b/drivers/android/binder.c > @@ -751,12 +757,16 @@ _binder_node_unlock(struct binder_node *node, int line) > #define binder_node_inner_lock(node) _binder_node_inner_lock(node, __LINE__) > static void > _binder_node_inner_lock(struct binder_node *node, int line) > + __acquires(&node->lock) __acquires(&node->proc->inner_lock) > { > binder_debug(BINDER_DEBUG_SPINLOCKS, > "%s: line=%d\n", __func__, line); > spin_lock(&node->lock); > if (node->proc) > binder_inner_proc_lock(node->proc); > + else > + /* annotation for sparse */ > + __acquire(&node->proc->inner_lock); This one is questionnable because: 1) if !node->proc, then '&node->proc->inner_lock' is not acquired since it doesn't even exist. 2) OTOH, the function can't have the annotation 100% right because it semantics allows unbalanced locking depending on node->proc being null or not. But I see very well the intent and maybe it's a right solution. I dunno. Same for most of the following ones. Best regards, -- Luc Van Oostenryck