Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp103772imm; Mon, 4 Jun 2018 13:53:34 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLfbomDaW2Acm6evtzkMNrRXobaFeqbbgBL6LfkF8bKa3qN+O2NflXJoC76O0ftviEJji13 X-Received: by 2002:a17:902:224:: with SMTP id 33-v6mr23055500plc.309.1528145614106; Mon, 04 Jun 2018 13:53:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528145614; cv=none; d=google.com; s=arc-20160816; b=GUbHzorXINOX2fCpeZyXWurzyJsnbzjMbBk3kcrNAIj9n8qsPzIqfygCV7sdWTC88N 0LGR/MV1L1FjvXHLWQCng3A6DL5OP5dw6lMEe0XytorouBjXWntWDex/cbOR0S5PoXuj c35rtEV/EJr7tIP7fdNdNeCM3AVFfmM83NnTUBLuygCiHfV7bcS1KFxUVrQnHDTKHMNV 6HuU9K7o4dcybeV0bDO/WSlBbZCO5qha2G8ruAO5x6DjzB/AZKMxiYMBV5bTUsAk1IDI /eABAYEPgptM/YSpYDKrmEN5EYbXt+qovTdjq6OPO1neQOyBxLTFTzbdGk+xmz0KTjVy vjMg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=Zw1DcfPXaQnIaH50PdrtLe6HfHprUJpBwF4ryyVew8E=; b=DExhIrBCDcw/PhYv0ZlgrfQrsFpOKURIkoCmQ1Q1pgsI8b+DfwDukG20uVLP1tkJPO hBDabJilSqXZ+2ryS4ymqz+yEbJaWl0LMF4HiYZB1edfyuJbZKAu8ulxsCGUU91GkQxU JTExPz3qwnT4xBcJu8jf2n+/WKKIsoikA56ns9MAAD6GyCOKli3WxzlBjZ3T5W3cWLbs 4USz6bbxd3vpCt+SZhQJX87ziSXX4YXh7xbMibewYGm2v0pj69oFbLjD2D62mDMuuNbB 5TBdYEfbQVMPPdCmWGqyJLNv5qHusVQHIgAwNSxMvlMriFAlYIzW9CJOxyXyy/xUyMxg EsqA== 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 x33-v6si46826366plb.512.2018.06.04.13.52.49; Mon, 04 Jun 2018 13:53:34 -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 S1751479AbeFDUvE (ORCPT + 99 others); Mon, 4 Jun 2018 16:51:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:50222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751228AbeFDUu1 (ORCPT ); Mon, 4 Jun 2018 16:50:27 -0400 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6989D20845; Mon, 4 Jun 2018 20:50:26 +0000 (UTC) Date: Mon, 4 Jun 2018 16:50:24 -0400 From: Steven Rostedt To: Mikulas Patocka Cc: Ingo Molnar , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: Re: [PATCH] branch-check: fix long->int truncation when profiling branches Message-ID: <20180604165024.3be78887@gandalf.local.home> In-Reply-To: References: <20180528155432.2864616-1-arnd@arndb.de> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 30 May 2018 08:19:22 -0400 (EDT) Mikulas Patocka wrote: > The function __builtin_expect returns long type (see the gcc > documentation), and so do macros likely and unlikely. Unfortunatelly, when > CONFIG_PROFILE_ANNOTATED_BRANCHES is selected, the macros likely and > unlikely expand to __branch_check__ and __branch_check__ truncates the Nice catch. > long type to int. This unintended truncation may cause bugs in various > kernel code (we found a bug in dm-writecache because of it), so it's I'm curious to what that bug was. > better to fix __branch_check__ to return long. > > Signed-off-by: Mikulas Patocka > Cc: stable@vger.kernel.org Anyway, I can pull this in my tree and test it. -- Steve > > --- > include/linux/compiler.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > Index: linux-2.6/include/linux/compiler.h > =================================================================== > --- linux-2.6.orig/include/linux/compiler.h 2018-02-26 20:34:17.000000000 +0100 > +++ linux-2.6/include/linux/compiler.h 2018-05-30 14:11:53.000000000 +0200 > @@ -21,7 +21,7 @@ void ftrace_likely_update(struct ftrace_ > #define unlikely_notrace(x) __builtin_expect(!!(x), 0) > > #define __branch_check__(x, expect, is_constant) ({ \ > - int ______r; \ > + long ______r; \ > static struct ftrace_likely_data \ > __attribute__((__aligned__(4))) \ > __attribute__((section("_ftrace_annotated_branch"))) \