Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp369527yba; Mon, 1 Apr 2019 08:02:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqx/fJqobnHH6z0lOb9gbuTw8HfNGvclbxxTWczO/mZ0cuYw1ZnSSpJK6PkBpgLotU2mX/xp X-Received: by 2002:a63:5ec2:: with SMTP id s185mr60864456pgb.27.1554130922561; Mon, 01 Apr 2019 08:02:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554130922; cv=none; d=google.com; s=arc-20160816; b=GNCFMEihk/aIlpw1prvlQtl24jjHRzjwv8+Sxecu/+d0UoDWtOu6jztTlAyqG8K0Fs dkqtDGzXmBpbJnU/iVRXRE/Hykar89dp68BsZDXNAPoUFRD8aPjQUwcxRAtOqZNi6KvI t8ySbb246cAtuMFQJZgxIOm5Q5AE/ICHBV8+qdWHVxzZeDZnte5dBJbQ/aGxe/pMlaoM Rr4bldzhlK1y4xtWpaw/FzFdMQldErFc+0qqDT/WZtTZPF8pup6eEfJ1GsNdcnNtVwMY YHwtIWU3D/3TPxO4WE6QFhoIMYcDua7fZe7d2L0+Wv2scNJisn3CLoUcabguPNTMPJoB izmQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=l7jNAnF6vluKh8XW+4HppBaLLV2wos1UJRlLQEOl/LA=; b=mmaTDaxl2hy3nrxhVXIUsQFOJZP+qnHEoyLSDqm+guN3NmDBoOEys8uCLpU9qlg8Cr MZuyREd3ojvt67tHZIYQusX4bpJc6PGMOLNvfPz4I8NH1hapaaIyDFQKxUfCW4VqQBz9 FVE4UcZmd8Po4wOwq2pVGTWSNASbTiYqTe6DINLS3Zm/Fa5wgPrNa9kkoocBm06rA0Js GozdO3SRlItAUvkuIqY6sNOY5NOVnPBUvXthHOH0ApWwdqvtPiYB+VKnCqz98V+2RN3x AyloY2dEbTwSjczAs0l5a8+zmD7poKpYK5/CAA12b8V9VV7wf8B4V2xyXfv3wVreMrBl faPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=lYQtmjWi; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m128si9319430pga.142.2019.04.01.08.01.45; Mon, 01 Apr 2019 08:02:02 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=lYQtmjWi; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728650AbfDAPAw (ORCPT + 99 others); Mon, 1 Apr 2019 11:00:52 -0400 Received: from mail-vs1-f67.google.com ([209.85.217.67]:44274 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726514AbfDAPAw (ORCPT ); Mon, 1 Apr 2019 11:00:52 -0400 Received: by mail-vs1-f67.google.com with SMTP id j184so5683344vsd.11 for ; Mon, 01 Apr 2019 08:00:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=l7jNAnF6vluKh8XW+4HppBaLLV2wos1UJRlLQEOl/LA=; b=lYQtmjWi4vlVPreI9e0sFX0A+Tu9l2DMboMenuDrnHS/U+LAdXHkOmoUVSE7//HYlT tUhHdClFIEkrSvUHlgep1Se9IQCMBSXYUAW3eZHFGjDkicofjn/kg7AFIRVD9joupGmP 5WjMSY5P3JoVowHr1MlCd39+w2wlMv/NUQW7MWKHELxhuyP8aEktfdEi0ehq5ast8U8M tSG2dDtBf3+QyTn9PCtdGmWuKWhb3NrPuYICCB5nxHsS2p0KSoeygo93VvZFNXfLNYWg VLMFfonSpmS/hzqYNpQ9GTyqbUq6nyBaQ27MhALTGCrB2/f79YtBEYbUsqDmFGlMosXa cJWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=l7jNAnF6vluKh8XW+4HppBaLLV2wos1UJRlLQEOl/LA=; b=knUD87LEVser4ZZ5Ey6O/M1DHdkfW8vB7/8grBpAdEbTB/m6rFHAIap8jl4uZXNGHS bKUjRU9beDGZutrNbB7i2rEUsIK3IteUvw8WKbVrOqLzdMEHsLYWVzDX/hl9b6ISpb7/ Q6yK6cbbdmh7vKrJOC11leKqNIi9vaeoJ2YraCkfPpK3Afti0J8hWeza3goEglibRfc/ 2j8XEn8vOoAHGAXl4FAFHIH8ym3070FyuwsEmFYB6YUemy8kD5a90KCiV5Oi7m8cN6V1 rrc45sJqm/Ua8Nnc6Y0QKbXg11tXPb9Zzl6Sy8J1yjUqHwf1uRIJ5UiAtSeB+9tPywrN DUiQ== X-Gm-Message-State: APjAAAVOwAuHU9Ahvxxa+wx93/80YwvM3Zfvzl6kG8QGTGn/xD0bHjWX p22En9vXlItu1i6k6mGV8EUEFrVhOxKGNdjG4qoQeg== X-Received: by 2002:a67:83c5:: with SMTP id f188mr37949466vsd.163.1554130850762; Mon, 01 Apr 2019 08:00:50 -0700 (PDT) MIME-Version: 1.0 References: <20190328162222.GO4102@linux.ibm.com> <8e32ab34-c14c-1ccb-76f9-0dcd729a0ef6@zytor.com> In-Reply-To: <8e32ab34-c14c-1ccb-76f9-0dcd729a0ef6@zytor.com> From: Alexander Potapenko Date: Mon, 1 Apr 2019 17:00:39 +0200 Message-ID: Subject: Re: Potentially missing "memory" clobbers in bitops.h for x86 To: "H. Peter Anvin" Cc: Paul McKenney , Peter Zijlstra , Ingo Molnar , LKML , Dmitriy Vyukov , James Y Knight Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 29, 2019 at 9:52 PM H. Peter Anvin wrote: > > On 3/29/19 8:54 AM, Alexander Potapenko wrote: > > > >> Of course, this would force the compiler to actually compute the > >> offset, which would slow things down. I have no idea whether this > >> would be better or worse than just using the "memory" clobber. > > Just adding the "memory" clobber to clear_bit() changes sizes of 5 > > kernel functions (the three mentioned above, plus hub_activate() and > > native_send_call_func_ipi()) by a small margin. > > This probably means the performance impact of this clobber is > > negligible in this case. > > I would agree with that. > > Could you perhaps verify whether or not any of the above functions > contains a currently manifest bug? Yes, I've checked that none of the above functions contain the bug. For a patch adding 7 memory constraints to various functions in bitops.h there are already 258 functions that change their size. I've skimmed through those with the biggest diffs and didn't find any flaws, but that can be just pure luck. I would expect such bugs to be more likely with full program optimization kicking in. > Note: the atomic versions of these functions obviously need to have > "volatile" and the clobber anyway, as they are by definition barriers > and moving memory operations around them would be a very serious error. > > -hpa > > > -- Alexander Potapenko Software Engineer Google Germany GmbH Erika-Mann-Stra=C3=9Fe, 33 80636 M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Paul Manicle, Halimah DeLaine Prado Registergericht und -nummer: Hamburg, HRB 86891 Sitz der Gesellschaft: Hamburg