Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4415329imm; Wed, 30 May 2018 05:22:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIZT6b7oHyTOg7TzHcn3scIL7IxNC7+N/65KM9TZZog44pDQntumBtKm/KQ/dkVExQ7cWO6 X-Received: by 2002:a62:1411:: with SMTP id 17-v6mr2600401pfu.3.1527682935428; Wed, 30 May 2018 05:22:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527682935; cv=none; d=google.com; s=arc-20160816; b=FFuueuQfyvL+ZthYtm5irjqWBYtFqdvtqv1BMArVQRxRgw5+PaXnAf6D2DvY373mTn Ma/zz1l74kiGf9I1Agx2n4FqubLrLpNvyOlXHY0WvXHuLd4eQsX721k3NTxgpjtMlbmW eSIWFpj3oxapUMTw0pzAkoGAXep65p0JiS6nFxYnckDsmi1kN1WjhxtTWvxyhWp5nWe8 7aHcG/lxjTgVl3VjApyGd9u5Jk4nkFzXYqwVx4791QYIimOU3jXhZxa3NYRQHEJWuqCK 6UTBV+P43Xta5NuDFlXD+jvr9TftHecWUtfFGg3VPVIxoGn2YUptWyQUFYGBUb9fONqG N54g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=UgO7mEdhFao8cMosbwA0p8oyLYk2gLrQnmStZZVshwk=; b=fbZ0IikoHjpmUKWoeDCGYecnuCYFKMdx8RAAJ8OPWDDPWSqF2bKdiD6CmxYbnBenFm TfnIOeumpUYo92k3jZb7HmZ7+Zsm93VhmgaBWThSHcSG8RZAi6fNFF/X7Se0xB7qbyHX fCIm6TuyckR2lEzOM1luR0wHfTXxo2BQK2sERcrTRQa9sxf3bwqeGGAIKJvspHni6FKG jZ8paLgzEb5kuFESxTv/N43TqZtqjkRLth/mgUORZXvlB4L4f6MGVxRyYySRxsewahB0 rM4YwVIg4nGJuhnpZkYlNQEESIQCZ2+hHh3zKoZq5vx8kEW4RAH9BbV+w+RlC9zV5ZD6 tQtA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si6021614pgn.308.2018.05.30.05.22.01; Wed, 30 May 2018 05:22:15 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753569AbeE3MT3 (ORCPT + 99 others); Wed, 30 May 2018 08:19:29 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:33784 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753056AbeE3MT1 (ORCPT ); Wed, 30 May 2018 08:19:27 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2854440201A0; Wed, 30 May 2018 12:19:27 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (file01.intranet.prod.int.rdu2.redhat.com [10.11.5.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 39A4463F25; Wed, 30 May 2018 12:19:23 +0000 (UTC) Received: from file01.intranet.prod.int.rdu2.redhat.com (localhost [127.0.0.1]) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4) with ESMTP id w4UCJNQr032443; Wed, 30 May 2018 08:19:23 -0400 Received: from localhost (mpatocka@localhost) by file01.intranet.prod.int.rdu2.redhat.com (8.14.4/8.14.4/Submit) with ESMTP id w4UCJNUJ032440; Wed, 30 May 2018 08:19:23 -0400 X-Authentication-Warning: file01.intranet.prod.int.rdu2.redhat.com: mpatocka owned process doing -bs Date: Wed, 30 May 2018 08:19:22 -0400 (EDT) From: Mikulas Patocka X-X-Sender: mpatocka@file01.intranet.prod.int.rdu2.redhat.com To: Steven Rostedt , Ingo Molnar cc: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, linux-kernel@vger.kernel.org, Arnd Bergmann Subject: [PATCH] branch-check: fix long->int truncation when profiling branches In-Reply-To: <20180528155432.2864616-1-arnd@arndb.de> Message-ID: References: <20180528155432.2864616-1-arnd@arndb.de> User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 30 May 2018 12:19:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 30 May 2018 12:19:27 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mpatocka@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 better to fix __branch_check__ to return long. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org --- 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"))) \