Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3324048ybl; Sun, 1 Sep 2019 10:40:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqyR1ZWr1WJo47heCuCvxgHqAhNcRApzi7RiK35dW8/OLNQuRsjlFRY6Vrw9fh5sCqY9MrMU X-Received: by 2002:aa7:81d1:: with SMTP id c17mr13803523pfn.219.1567359643725; Sun, 01 Sep 2019 10:40:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567359643; cv=none; d=google.com; s=arc-20160816; b=tKBDPgkQXQLSW7FcbIuk0TDC9fNLGSEAMFVRHv6t42MdwetLc3oYI3N3IMM0suXjja 0X9fqkjQSAsJb8wK8TgjC8tM2Hjeu54CKBCpTNYEI72BkuELhNl/lJ6zFGLZzmF3VnCa ZyIWDlOSRK5PyRHbOlRGJxrdzlfqHbYV13P3o+0Zc77bVf32GvTCc/wlu65jSp5vrAO3 gY2+tw/bxlAI8rfrKsV3S+xjdOeMZg/E5SBaPC2vDKixe6EEYQWb5GV0M2mcLWFB2ZYs IbjC7f6qM3mVIQ7nQLCVHyvXBrJE0MNkAI0/4TVRpe8qNGY1BJfCaZ71QoLioy7JMZyU 5quQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=0wSbAT31pUQLK0avkX7bfMBXJEaiMB9FtdWtd8fTkuI=; b=EJl1Jm0+SwY0EXKVU2EdEQK18lGtuGUkrISvj27bW3o8OXPCpRqHxppasJntW7OOhU ZRBIQqx6KdS2R3Wc6TUqXXr2NlzmLH65ayM/Lj5nz8Pkcezwq5j1eJCeCm3Q+lbh7PNn d9S45t7EHTGNc3x1mPio3TUeEIdV1qewZoQ3nuQ4+QVFQITmZLkYufFib+QHhDFYqTgE 59TCe5be+5qbUveUlGuxCn3kxhh9Gs7Teez9uzIByhkboRSg/2C5kF/UOQVrwvGvBPtu 4/nkUIARk6o0sy+797fjacY35Qw7fPPpdpT1efXWzlvflyjJHNTNe2vmzan+gQnd7AAC yEPw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y16si12205806pfc.51.2019.09.01.10.40.28; Sun, 01 Sep 2019 10:40:43 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728952AbfIARjd (ORCPT + 99 others); Sun, 1 Sep 2019 13:39:33 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34789 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728830AbfIARjd (ORCPT ); Sun, 1 Sep 2019 13:39:33 -0400 Received: by mail-ed1-f66.google.com with SMTP id s49so13714302edb.1 for ; Sun, 01 Sep 2019 10:39:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0wSbAT31pUQLK0avkX7bfMBXJEaiMB9FtdWtd8fTkuI=; b=oYgQjtM8mllNZjqn3AcTOqOUht/+b+Dp35/Uwbs1riI0wwtNEUDINzNTiuy29+7nd0 lKuB8UHheb+Mb3qeUVAgH+Tg/yJAGmMyWt17TkCcgTYLepIcO0Vl2/Bi5PYqNPBJHsEO 2dqMzima9gp2dJX833/APAnGRdRe5LrZuut1O8F37xBbBnzRnfJfVBTdIUtuju+Fw558 SilyEYRmqpF510w56K5j9CNGmQwYgtlHx4VpxBkv+vBfOC/+yqaqPWe1mm1f1L7k/4O1 r6HCrxwgNjlM7c1COPPTgjjHXeVWEMMxWBBra1CdvqlosqfOgs0wtmHfIHjaRX8CDIJ5 zfRQ== X-Gm-Message-State: APjAAAWVD8bDJbf7ykugXYwJlkV2yNR/eRv+wuMpMiQzwkjyr84yJeNa RuZYGM3upKetD9HG0jRmOOtF5kDKKZo= X-Received: by 2002:aa7:db0c:: with SMTP id t12mr13449835eds.297.1567359571711; Sun, 01 Sep 2019 10:39:31 -0700 (PDT) Received: from [10.68.32.192] (broadband-188-32-48-208.ip.moscow.rt.ru. [188.32.48.208]) by smtp.gmail.com with ESMTPSA id qt5sm231872ejb.11.2019.09.01.10.39.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Sep 2019 10:39:31 -0700 (PDT) Subject: Re: [PATCH] scripts: coccinelle: check for !(un)?likely usage To: Pavel Machek , Joe Perches Cc: cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org, Julia Lawall , Gilles Muller , Nicolas Palix , Michal Marek References: <20190825130536.14683-1-efremov@linux.com> <20190901172403.GA1047@bug> From: Denis Efremov Message-ID: <45362841-2ae6-e946-2ae0-ab56a98f15ca@linux.com> Date: Sun, 1 Sep 2019 20:39:30 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190901172403.GA1047@bug> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01.09.2019 20:24, Pavel Machek wrote: > Hi! > >>> This patch adds coccinelle script for detecting !likely and !unlikely >>> usage. It's better to use unlikely instead of !likely and vice versa. >> >> Please explain _why_ is it better in the changelog. >> >> btw: there are relatively few uses like this in the kernel. >> >> $ git grep -P '!\s*(?:un)?likely\s*\(' | wc -l >> 40 >> >> afaict: It may save 2 bytes of x86/64 object code. >> >> For instance: >> >> $ diff -urN kernel/tsacct.lst.old kernel/tsacct.lst.new|less >> --- kernel/tsacct.lst.old 2019-08-25 09:21:39.936570183 -0700 >> +++ kernel/tsacct.lst.new 2019-08-25 09:22:20.774324886 -0700 >> @@ -24,158 +24,153 @@ >> 15: 48 89 fb mov %rdi,%rbx >> u64 time, delta; >> >> - if (!likely(tsk->mm)) >> + if (unlikely(tsk->mm)) > > Are you sure this is equivalent? > > Pavel Hi, No, it's not correct. Thanks Rasmus for clarifying the things here. This was my mistake. As a human, I failed to parse "likely" and "!" and made too hasty conclusions :) The correct transformation is in v2. This will be !likely(tsk->mm) -> unlikely(!tsk->mm) Thanks, Denis