Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4403643ybb; Tue, 14 Apr 2020 06:41:12 -0700 (PDT) X-Google-Smtp-Source: APiQypJXvWtxoypXxvjjm5PZYcBcRvkm1h/CBxdeWuULh9GSdk17eoxCZPWOz/17mZ1W5wEXZSV4 X-Received: by 2002:aa7:d88c:: with SMTP id u12mr9965370edq.362.1586871672393; Tue, 14 Apr 2020 06:41:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586871672; cv=none; d=google.com; s=arc-20160816; b=V3B9AIMWKQ0wmJYyp1TBJP+2NVjJyRAzcy0LVEIPq6kUAaGvWuNFSPF5TkkmSjKvIu 08W9Qivwr2twinyfTFKOlU6l7ytos3CX5LvXWsuXMpzSmdMPzaltBNmRODS+yMWh8Jbc 7hoyffuqyQrhxIIiFUNtLedpzS5YFtMB8hmO0Gx3Xxi9Iwa3mgdRwDIgSZsx27dYtgVP H6iIqJ9rjQzu1d21ZADwRG/ZjDjOaheVNiMCIS//j60WVLzFrA3GQ/7rdAhb9h/P8PsA 7+7rAE0KlxdSc3X/6I1xPE1dEP0FunHx0iimAAdHUqOPW3/ISPI6jd7fIhnMLnfmOxXK iNhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=afpWVAYpzZoZj0cDvbL8nrVqxs7nYxlOztCZvs4WtUQ=; b=olA8loueMSo/Ob+mdsCoYR02r6E0RqlJ/eSzd3dgpT5uhrnsUL7BttbqvgO/nCXlrA AP3JHhbvl/qwScAnviHfAo9YKKPBtHXcltOEKTU/Ssz6/rdMeW0zTpp4K/5f8d47vDoJ gG+Jppm5QtaBMPoyRGHwPcpSI1nN0YtkqGjIpHqaRmATh3ZBy2K5TGibM53bhFYarsLw B2xL/z0lE3kj4fWVQ4hycSrviuI3NwSAOL3drHsp/Px177R8e+PFujHk1JhVmXJnNuBF Deyum4ZllVeh3sh/ufA50nRPl4UIcLBwzB0bI+OObDSPmToIfK1Ko5mLhPADstVaYVwj YU6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n4GgF6Zv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id p13si8103898ejo.283.2020.04.14.06.40.49; Tue, 14 Apr 2020 06:41:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=n4GgF6Zv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2389205AbgDMVnI (ORCPT + 99 others); Mon, 13 Apr 2020 17:43:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S2388914AbgDMVnF (ORCPT ); Mon, 13 Apr 2020 17:43:05 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70E84C0A3BDC; Mon, 13 Apr 2020 14:43:05 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id k1so4646888wrx.4; Mon, 13 Apr 2020 14:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=afpWVAYpzZoZj0cDvbL8nrVqxs7nYxlOztCZvs4WtUQ=; b=n4GgF6ZvxeiMQzKcLPJYat0oTylnX+JU8HeEovMVSF3wH7koxJ/qhOk8Rx8OsZv2ZU M/ouFWf+mujWlix45liM6rESmfaaySYkc4WbrHKEzprG80Tw6oCUi6AK2qopMck8TNLX vCvCiNaPj5g/etB57fWlQx59B4vGjQh/IH95iiXlz1YWQAal1oWT20c38lnRF1kR1pcy fMvDilMbH/oi9r8YRgjLOHrcwfx2OWxRIdqv4Tjw5zY+A7rRDZmY2sl6S6nw+FdmixRh WO0cviCLsO5h3p5ZyVJBB6rDenpX6C4U8l7wP3qL+Vz3cNO8zQN1DbiH7SnGkBpmgpqB 8fKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=afpWVAYpzZoZj0cDvbL8nrVqxs7nYxlOztCZvs4WtUQ=; b=WHeTLrKLR8AYA8U0rcJv4+a/WMy961JV5jr0bXbMtrdLns9okS2CWZqgDZecbWcpiZ AEhXFGcqbFRhi79fPp+e1X466kj2VQwzLSFeWB/qZaUWktqdun9TSVEJNnXkvPWNZ9y4 CZ1BgEnmugOK7/QV1D00lBSwmCccsMT2t6COAA096daQ2beYRWWB2rNU2HAGotz70XSB +ihj33UZOkQr09kgwdZBRcoBUOVB3GfzNaovD0RLvH6gw7NrNPDVndJNpBR7DDK8AzjZ WVvNXiR9baUQrw7hcOb9YNo//E+usd6l5kbUQCWfeF72Fp81a23YQtTz4arLxjPs00GJ SMhw== X-Gm-Message-State: AGi0PuYwszpaPiYBRenu0iMAN2jO8x+HEOBVpr+XQPyDQ7xZaT3fJ1Fi nvbVUvXCrH8MOzB+PfIjGABzpc3D3Q== X-Received: by 2002:a5d:6a10:: with SMTP id m16mr22341815wru.371.1586814183920; Mon, 13 Apr 2020 14:43:03 -0700 (PDT) Received: from ninjahost.lan (79-73-33-244.dynamic.dsl.as9105.com. [79.73.33.244]) by smtp.gmail.com with ESMTPSA id 1sm15597703wmi.0.2020.04.13.14.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2020 14:43:03 -0700 (PDT) From: Jules Irenge To: linux-kernel@vger.kernel.org Cc: boqun.feng@gmail.com, Jan Kara , Amir Goldstein , linux-fsdevel@vger.kernel.org (open list:FSNOTIFY: FILESYSTEM NOTIFICATION INFRASTRUCTURE) Subject: [PATCH v2] fsnotify: Add missing annotation for fsnotify_finish_user_wait() and for fsnotify_prepare_user_wait() Date: Mon, 13 Apr 2020 22:42:40 +0100 Message-Id: <20200413214240.15245-1-jbi.octave@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse reports warnings at fsnotify_prepare_user_wait() and at fsnotify_finish_user_wait() warning: context imbalance in fsnotify_finish_user_wait() - wrong count at exit warning: context imbalance in fsnotify_prepare_user_wait() - unexpected unlock The root cause is the missing annotation at fsnotify_finish_user_wait() and at fsnotify_prepare_user_wait() fsnotify_prepare_user_wait() has an extra annotation __release() that only tell Sparse and not GCC to shutdown the warning Add the missing __acquires(&fsnotify_mark_srcu) annotation Add the missing __releases(&fsnotify_mark_srcu) annotation Add the __release(&fsnotify_mark_srcu) annotation. Signed-off-by: Jules Irenge --- changes since v2 -include annotations for fsnotify_prepare_user_wait() fs/notify/mark.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/notify/mark.c b/fs/notify/mark.c index 1d96216dffd1..8387937b9d01 100644 --- a/fs/notify/mark.c +++ b/fs/notify/mark.c @@ -325,13 +325,16 @@ static void fsnotify_put_mark_wake(struct fsnotify_mark *mark) } bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info) + __releases(&fsnotify_mark_srcu) { int type; fsnotify_foreach_obj_type(type) { /* This can fail if mark is being removed */ - if (!fsnotify_get_mark_safe(iter_info->marks[type])) + if (!fsnotify_get_mark_safe(iter_info->marks[type])) { + __release(&fsnotify_mark_srcu); goto fail; + } } /* @@ -350,6 +353,7 @@ bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info) } void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info) + __acquires(&fsnotify_mark_srcu) { int type; -- 2.24.1