From patchwork Wed Oct 30 14:22:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Potapenko X-Patchwork-Id: 11219609 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 39F3E1668 for ; Wed, 30 Oct 2019 14:22:52 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id F061A208C0 for ; Wed, 30 Oct 2019 14:22:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kdRaR3sd" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F061A208C0 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C260C6B000A; Wed, 30 Oct 2019 10:22:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AE5EB6B000C; Wed, 30 Oct 2019 10:22:50 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B21D6B000D; Wed, 30 Oct 2019 10:22:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 771B56B000A for ; Wed, 30 Oct 2019 10:22:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id 293F08249980 for ; Wed, 30 Oct 2019 14:22:50 +0000 (UTC) X-FDA: 76100667300.13.gun41_35cff63b97d47 X-Spam-Summary: 2,0,0,6cd9ffa039ee03c8,d41d8cd98f00b204,3ujy5xqykcmsx2zuv8x55x2v.t532z4be-331crt1.58x@flex--glider.bounces.google.com,:vegard.nossum@oracle.com:dvyukov@google.com::viro@zeniv.linux.org.uk:akpm@linux-foundation.org:aryabinin@virtuozzo.com:luto@kernel.org:ard.biesheuvel@linaro.org:arnd@arndb.de:hch@lst.de:dmitry.torokhov@gmail.com:edumazet@google.com:ericvh@gmail.com:gregkh@linuxfoundation.org:harry.wentland@amd.com:herbert@gondor.apana.org.au:mingo@elte.hu:axboe@kernel.dk:martin.petersen@oracle.com:schwidefsky@de.ibm.com:mst@redhat.com:monstr@monstr.eu:pmladek@suse.com:sergey.senozhatsky@gmail.com:rostedt@goodmis.org:tiwai@suse.com:tytso@mit.edu:tglx@linutronix.de:wsa@the-dreams.de:gor@linux.ibm.com:iii@linux.ibm.com:mark.rutland@arm.com:willy@infradead.org:rdunlap@infradead.org:andreyknvl@google.com:elver@google.com:glider@google.com,RULES_HIT:41:152:355:379:541:800:960:973:988:989:1260:1277:1313:1314:1345:1359:1437:1516:1518:1534:1541:1593:1594:1711:1730:1747 :1777:17 X-HE-Tag: gun41_35cff63b97d47 X-Filterd-Recvd-Size: 4361 Received: from mail-vs1-f74.google.com (mail-vs1-f74.google.com [209.85.217.74]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Wed, 30 Oct 2019 14:22:49 +0000 (UTC) Received: by mail-vs1-f74.google.com with SMTP id d75so285388vsc.11 for ; Wed, 30 Oct 2019 07:22:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=plzgBrf4XRluLUj/PzB2ncSNnS5pEmW2k0rQhwkYJ7A=; b=kdRaR3sdQBRFSQzy8k+qX2Ad2lD40/rMbvRzTdqm9P0URN3NYQg8QiPJkdvVq10Z72 iZIdcPHXl/lnyYKfVdLSy9U4VNql/q0GSpGrhyI0csAsua40PuWZPyI4A0Q8zYz+5qoC CYtHhRJCBzaFae0g5j8/GrlLWUMYUKNDYM+E08bUR68QFUtfj0S12Gbjf2m3BdcO3rry Nx5WbnJuEJyxenjM3aOT6z9OuE18Yjxi/jXPF0uGkY+zC47BQS3hoim1SGGu9pmjNBQD RvXezbSzZHc2MGYQVffqEj1NUTs1rZq65WEoykDs7jq5L11k17S1PpGD1h701mdLUBfg 4MXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=plzgBrf4XRluLUj/PzB2ncSNnS5pEmW2k0rQhwkYJ7A=; b=a45T+bNw4q0XjCXgiDtjOU9O3ZDKW8F3VVkNnoCZxZs1N2Gh8TkxzSJkddnyNnu9Wq 7qXOHg4QisXrQu+aOxCqs9e/5bpLChIGOymW7JY1DwjkqIZMjz//RGiqhWEzfq1SWfmr 54g6LERdTY0rFEg06eQZE2k8NRle6VK/bx+DVbW3A8s9GOJhgaueI9rIIVosh4zhJtUo 5FR9d7DR7X/WykDV9PEseahI8Pg2Mvknze1+hZ372bA1ZviE2RlLArnfvr2Xn2WouWS6 nel/WjaQs9g7Grj4WcicwmyAoqVy/EzXaO7fPw+GgjW4/2lD0Lg+mcM0c/W/X6o31Z2w FKNw== X-Gm-Message-State: APjAAAU38oZYUDpofaZTkgBP8hyYI9ASQug8PhRdVn/0TmO+ZBY17qUm N5f6zwg5R/YkY8/x6X8FEwWciSjQTEE= X-Google-Smtp-Source: APXvYqwBK0+xQJstq3eyLZqF11CvHzgFRdSrO1R/vDHGepI3fxsD68olJqtwEeqpCRTtHQT9uyYRhgEyfIU= X-Received: by 2002:a1f:c441:: with SMTP id u62mr14905093vkf.88.1572445368591; Wed, 30 Oct 2019 07:22:48 -0700 (PDT) Date: Wed, 30 Oct 2019 15:22:14 +0100 In-Reply-To: <20191030142237.249532-1-glider@google.com> Message-Id: <20191030142237.249532-3-glider@google.com> Mime-Version: 1.0 References: <20191030142237.249532-1-glider@google.com> X-Mailer: git-send-email 2.24.0.rc0.303.g954a862665-goog Subject: [PATCH RFC v2 02/25] stackdepot: prevent Clang from optimizing away stackdepot_memcmp() From: glider@google.com To: Vegard Nossum , Dmitry Vyukov , linux-mm@kvack.org Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org, aryabinin@virtuozzo.com, luto@kernel.org, ard.biesheuvel@linaro.org, arnd@arndb.de, hch@lst.de, dmitry.torokhov@gmail.com, edumazet@google.com, ericvh@gmail.com, gregkh@linuxfoundation.org, harry.wentland@amd.com, herbert@gondor.apana.org.au, mingo@elte.hu, axboe@kernel.dk, martin.petersen@oracle.com, schwidefsky@de.ibm.com, mst@redhat.com, monstr@monstr.eu, pmladek@suse.com, sergey.senozhatsky@gmail.com, rostedt@goodmis.org, tiwai@suse.com, tytso@mit.edu, tglx@linutronix.de, wsa@the-dreams.de, gor@linux.ibm.com, iii@linux.ibm.com, mark.rutland@arm.com, willy@infradead.org, rdunlap@infradead.org, andreyknvl@google.com, elver@google.com, Alexander Potapenko X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Clang may replace stackdepot_memcmp() with a call to instrumented bcmp(), which is exactly what we wanted to avoid creating stackdepot_memcmp(). Add a compiler barrier() to prevent optimizations. Signed-off-by: Alexander Potapenko To: Alexander Potapenko Cc: Vegard Nossum Cc: Dmitry Vyukov Cc: linux-mm@kvack.org --- Change-Id: I4495b617b15c0ab003a61c1f0d54d0026fa8b144 --- lib/stackdepot.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/stackdepot.c b/lib/stackdepot.c index 0d00d2ac0c4b..785839298e08 100644 --- a/lib/stackdepot.c +++ b/lib/stackdepot.c @@ -163,6 +163,11 @@ int stackdepot_memcmp(const unsigned long *u1, const unsigned long *u2, unsigned int n) { for ( ; n-- ; u1++, u2++) { + /* + * Prevent Clang from replacing this function with a bcmp() + * call. + */ + barrier(); if (*u1 != *u2) return 1; }