From patchwork Thu Sep 22 09:43:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 9344887 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A49CE60757 for ; Thu, 22 Sep 2016 09:44:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95C1A2A929 for ; Thu, 22 Sep 2016 09:44:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 884462A92B; Thu, 22 Sep 2016 09:44:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F42042A929 for ; Thu, 22 Sep 2016 09:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756144AbcIVJoG (ORCPT ); Thu, 22 Sep 2016 05:44:06 -0400 Received: from mx2.suse.de ([195.135.220.15]:33702 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750714AbcIVJoE (ORCPT ); Thu, 22 Sep 2016 05:44:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B17CCAAEF; Thu, 22 Sep 2016 09:44:02 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 7A48D1E1168; Thu, 22 Sep 2016 11:44:01 +0200 (CEST) From: Jan Kara To: Andrew Morton Cc: linux-fsdevel@vger.kernel.org, Heiner Kallweit , Jan Kara Subject: [PATCH] fsnotify: Cleanup spinlock assertions Date: Thu, 22 Sep 2016 11:43:59 +0200 Message-Id: <1474537439-18919-1-git-send-email-jack@suse.cz> X-Mailer: git-send-email 2.6.6 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use assert_spin_locked() macro instead of hand-made BUG_ON statements. Suggested-by: Heiner Kallweit Signed-off-by: Jan Kara Reviewed-by: Jeff Layton --- fs/notify/fanotify/fanotify_user.c | 3 +-- fs/notify/notification.c | 9 +++------ 2 files changed, 4 insertions(+), 8 deletions(-) Andrew, can you please add this cleanup to the fanotify patches you carry? Thanks! diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c index 189fab3ac4e6..7ebfca6a1427 100644 --- a/fs/notify/fanotify/fanotify_user.c +++ b/fs/notify/fanotify/fanotify_user.c @@ -54,8 +54,7 @@ struct kmem_cache *fanotify_perm_event_cachep __read_mostly; static struct fsnotify_event *get_one_event(struct fsnotify_group *group, size_t count) { - BUG_ON(IS_ENABLED(CONFIG_SMP) && - !spin_is_locked(&group->notification_lock)); + assert_spin_locked(&group->notification_lock); pr_debug("%s: group=%p count=%zd\n", __func__, group, count); diff --git a/fs/notify/notification.c b/fs/notify/notification.c index 1a8010e7a2a0..66f85c651c52 100644 --- a/fs/notify/notification.c +++ b/fs/notify/notification.c @@ -63,8 +63,7 @@ EXPORT_SYMBOL_GPL(fsnotify_get_cookie); /* return true if the notify queue is empty, false otherwise */ bool fsnotify_notify_queue_is_empty(struct fsnotify_group *group) { - BUG_ON(IS_ENABLED(CONFIG_SMP) && - !spin_is_locked(&group->notification_lock)); + assert_spin_locked(&group->notification_lock); return list_empty(&group->notification_list) ? true : false; } @@ -149,8 +148,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group) { struct fsnotify_event *event; - BUG_ON(IS_ENABLED(CONFIG_SMP) && - !spin_is_locked(&group->notification_lock)); + assert_spin_locked(&group->notification_lock); pr_debug("%s: group=%p\n", __func__, group); @@ -172,8 +170,7 @@ struct fsnotify_event *fsnotify_remove_first_event(struct fsnotify_group *group) */ struct fsnotify_event *fsnotify_peek_first_event(struct fsnotify_group *group) { - BUG_ON(IS_ENABLED(CONFIG_SMP) && - !spin_is_locked(&group->notification_lock)); + assert_spin_locked(&group->notification_lock); return list_first_entry(&group->notification_list, struct fsnotify_event, list);