From patchwork Thu Aug 29 16:50:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11121905 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3333014E5 for ; Thu, 29 Aug 2019 16:51:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1BF8E2339E for ; Thu, 29 Aug 2019 16:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfH2Quy (ORCPT ); Thu, 29 Aug 2019 12:50:54 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:38855 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbfH2Qux (ORCPT ); Thu, 29 Aug 2019 12:50:53 -0400 Received: by mail-wm1-f67.google.com with SMTP id o184so4553699wme.3; Thu, 29 Aug 2019 09:50:51 -0700 (PDT) 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=EAPNXwtNcvomkAv43HK7BcSQSi3ID9bH+hr63tWVdSI=; b=B5HGm8Y0d+BC3TOmZ23uuf+WqGqYOV7ombVlzG70cKlsV5JRtEvvNhzfPX4mECWFhx u5j/9cXAx5IqdKYxp7N//EOr02YdCxMO9TImOTBYGSfNXGWuDvoj6pJX11SgB//Tt5im yYal4ni8RQu92gT5EGlqUSz2C0ZgmGFTTf+a6stQq6hqSBqIOsB4/FaV7WQu1kPe6C3X +xLocX36sKRkLLs3x2PB2D+myD7iamK/wRKiMKBKp2+VCm7/qCDUbUDyTARThORMu67E QuOMPvFXZtlfAMMmQxgNFbLz16ewEqahiYYT8vzew1IHcjJ1Y165M5UTbENb5n3dJ24k kxqA== X-Gm-Message-State: APjAAAX+kGHw6qYwNcIPCIAbgM17lyiHVPh/qD8mC15U8cFFX3Ij61QJ D4+f5ZSeYUoFEP3fmz575wgwXYvwuHo= X-Google-Smtp-Source: APXvYqyG8Uv9qqAEzfuwRYVShx38vJV1pUSPq3W7ZBAlPx5+N1oEiU4zijmswr1WDwZJj2S7mhEW8w== X-Received: by 2002:a1c:f704:: with SMTP id v4mr361727wmh.90.1567097450438; Thu, 29 Aug 2019 09:50:50 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id o14sm8340770wrg.64.2019.08.29.09.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 09:50:49 -0700 (PDT) From: Denis Efremov To: linux-kernel@vger.kernel.org Cc: Denis Efremov , Alexander Viro , Anton Altaparmakov , Boris Ostrovsky , Boris Pismenny , "Darrick J. Wong" , "David S. Miller" , Dennis Dalessandro , Dmitry Torokhov , Inaky Perez-Gonzalez , Juergen Gross , Leon Romanovsky , Mike Marciniszyn , =?utf-8?q?Pali_Roh=C3=A1r?= , Rob Clark , Saeed Mahameed , Sean Paul , linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-input@vger.kernel.org, linux-ntfs-dev@lists.sourceforge.net, linux-rdma@vger.kernel.org, linux-wimax@intel.com, linux-xfs@vger.kernel.org, xen-devel@lists.xenproject.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Joe Perches , Andrew Morton , Andy Whitcroft Subject: [PATCH v3 01/11] checkpatch: check for nested (un)?likely() calls Date: Thu, 29 Aug 2019 19:50:15 +0300 Message-Id: <20190829165025.15750-1-efremov@linux.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org IS_ERR(), IS_ERR_OR_NULL(), IS_ERR_VALUE() and WARN*() already contain unlikely() optimization internally. Thus, there is no point in calling these functions and defines under likely()/unlikely(). This check is based on the coccinelle rule developed by Enrico Weigelt https://lore.kernel.org/lkml/1559767582-11081-1-git-send-email-info@metux.net/ Signed-off-by: Denis Efremov Cc: Joe Perches Cc: Andrew Morton Cc: Andy Whitcroft --- scripts/checkpatch.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 93a7edfe0f05..56969ce06df4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6480,6 +6480,12 @@ sub process { "Using $1 should generally have parentheses around the comparison\n" . $herecurr); } +# nested likely/unlikely calls + if ($line =~ /\b(?:(?:un)?likely)\s*\(\s*!?\s*(IS_ERR(?:_OR_NULL|_VALUE)?|WARN)/) { + WARN("LIKELY_MISUSE", + "nested (un)?likely() calls, $1 already uses unlikely() internally\n" . $herecurr); + } + # whine mightly about in_atomic if ($line =~ /\bin_atomic\s*\(/) { if ($realfile =~ m@^drivers/@) { From patchwork Thu Aug 29 16:50:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis Efremov (Oracle)" X-Patchwork-Id: 11121913 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D5C1A14E5 for ; Thu, 29 Aug 2019 16:51:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BE15D23403 for ; Thu, 29 Aug 2019 16:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728084AbfH2Qvb (ORCPT ); Thu, 29 Aug 2019 12:51:31 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:42135 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726973AbfH2Qva (ORCPT ); Thu, 29 Aug 2019 12:51:30 -0400 Received: by mail-wr1-f68.google.com with SMTP id b16so4136342wrq.9; Thu, 29 Aug 2019 09:51:29 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=ax9lthaK3JhQ59ymHdiiPSvPPTi+y1ZSO3PCkFb2G5c=; b=ihD8QLtJevBClQBmt7qVK24jqzxyAW5XpySoXrPKXW+9LBP22kDWd4z7HKKtaA8vTj kjV6+TJ8gT+BApAlM/rtjIqzsFZYEIcaoUfEWiF5EZhVFZj+X3zlyUEEn5oJlKHxB90q re9S/3yf8dgCKuU1DJ6k55GUGBe1d7y+u4/SQtWaovWTptCU5q2i3K5aYzB3K7/uSLGh BYKXPUfSdsalFCsZyfuHHy67tF/z14PfZz1+FypFpuIR/DEeiGrLHOt+ra4ahY3SF+Ay Kv+xDPYbEcI8zuRVj1IsqsQDW4NhXduDkmcVtuuzlzBUcjButcp4g2fndiBBWl6aX7LR 60uw== X-Gm-Message-State: APjAAAWxfo45RmlAr/4RW1N64clRn5kbjFdhfR6vZuGeQS0SlHErPZMg FXQjoaxmZomub4Wl4647/ozDuf8e8sw= X-Google-Smtp-Source: APXvYqwNCX5KpCkJvjt3Q24LOmT9KyMwfdz46BXc98KC+dRLdeECTISprmN61E3Jdwt/Xriho/gXZA== X-Received: by 2002:a05:6000:1189:: with SMTP id g9mr13825551wrx.51.1567097488358; Thu, 29 Aug 2019 09:51:28 -0700 (PDT) Received: from green.intra.ispras.ru (bran.ispras.ru. [83.149.199.196]) by smtp.googlemail.com with ESMTPSA id o14sm8340770wrg.64.2019.08.29.09.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2019 09:51:27 -0700 (PDT) From: Denis Efremov To: linux-kernel@vger.kernel.org Cc: Denis Efremov , Alexander Viro , Joe Perches , Andrew Morton , linux-fsdevel@vger.kernel.org Subject: [PATCH v3 05/11] fs: remove unlikely() from WARN_ON() condition Date: Thu, 29 Aug 2019 19:50:19 +0300 Message-Id: <20190829165025.15750-5-efremov@linux.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190829165025.15750-1-efremov@linux.com> References: <20190829165025.15750-1-efremov@linux.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org "unlikely(WARN_ON(x))" is excessive. WARN_ON() already uses unlikely() internally. Signed-off-by: Denis Efremov Cc: Alexander Viro Cc: Joe Perches Cc: Andrew Morton Cc: linux-fsdevel@vger.kernel.org --- fs/open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/open.c b/fs/open.c index a59abe3c669a..9432cd5a8294 100644 --- a/fs/open.c +++ b/fs/open.c @@ -776,7 +776,7 @@ static int do_dentry_open(struct file *f, f->f_mode |= FMODE_ATOMIC_POS; f->f_op = fops_get(inode->i_fop); - if (unlikely(WARN_ON(!f->f_op))) { + if (WARN_ON(!f->f_op)) { error = -ENODEV; goto cleanup_all; }