From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8538C432C3 for ; Wed, 13 Nov 2019 16:41:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 077C520658 for ; Wed, 13 Nov 2019 16:41:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573663261; bh=u70FTkIfHr0s5GeiochXVYbVDgHJlfOaLAB1vLa2K5E=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=ZFLkmG6ABqijc/NsFGnx3+AlFxtyWpaF2SufSQpLXz9ZDhAGrCj+MwBlD+gf6eb2r I7X4l5cYvZIAnDUGyb5oCrdD84squU0cCVEnvfffEWyUGIFcUdwv1KlfBoN4SYi/06 0IjErZBiyPEnRjg/FhDwP7K1YZboVX7KHA4skoOI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727881AbfKMQlB (ORCPT ); Wed, 13 Nov 2019 11:41:01 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:38335 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727687AbfKMQlB (ORCPT ); Wed, 13 Nov 2019 11:41:01 -0500 Received: by mail-lf1-f65.google.com with SMTP id q28so2509909lfa.5 for ; Wed, 13 Nov 2019 08:40:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IXJjwxWVC55yLVrTrqMlfhMslA2YmSoPCmuWxQ9Z1yA=; b=hBBa3CeKyqP0PPhoeL6NBNaKCWmnnCm42FJMebd8vhB9frKHZbx/LVLxNigeYeeSyf Tr9US9KNUDjInwfvRwXHyNa4DeqDgvfhgO7Bbq+xFPMkcEXTZsq5M/y0tPhks9KaQJcN CurISmPdkfK1RyWNlXatFqKzg9omOPzuFCsrk= 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; bh=IXJjwxWVC55yLVrTrqMlfhMslA2YmSoPCmuWxQ9Z1yA=; b=JE6pZMk/15nnLdHR58OnJIdaPB/s9nq/2wL9Nz8nFmkWRs+wQDw8UoPZ3ZmJfLgUEC YOnVQuQPQ/qL1M0EBBvxWJxVxDo204Zh61+Md2DlDIfXVL/lVGHjxatmSMRCxaHOGyYo HgKGuEHlX+hhHJ3fZSQhTNNmorC6I/K/yJgzbegg4n9gtk4gd8nk9mS1kFwwrP2k8Y/K XHIHPvDUXaL+KT9QJMVFgHOUDqMCIlA/gAjDoahn9qAs2bDXxgO4NTlqG+YioVMHTjvH GHEv+oNNezGHDOL9kga4HuHjhz7+MGPdkBONlWx3q96asbXNdW85+Gjz3g1Ty3YTxKtg dfUg== X-Gm-Message-State: APjAAAUlc/qu2W2vEB4SkJD73jcWQjXTGhktNoolt2vMLSTtDNHCgbRc mS/G7ZNCre1aFu74pAFuD0jsA83KOVk= X-Google-Smtp-Source: APXvYqx8BE829VJlEJjYa/HeGmKDUGYaAlu9EnJxncemVWAUxSZrZF0EXC7mybqGHVBydcxSR4qRlQ== X-Received: by 2002:ac2:484a:: with SMTP id 10mr3266452lfy.80.1573663258517; Wed, 13 Nov 2019 08:40:58 -0800 (PST) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com. [209.85.167.48]) by smtp.gmail.com with ESMTPSA id p14sm1105423ljc.8.2019.11.13.08.40.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Nov 2019 08:40:57 -0800 (PST) Received: by mail-lf1-f48.google.com with SMTP id j26so2498995lfh.7 for ; Wed, 13 Nov 2019 08:40:57 -0800 (PST) X-Received: by 2002:ac2:5bca:: with SMTP id u10mr3466591lfn.134.1573663257105; Wed, 13 Nov 2019 08:40:57 -0800 (PST) MIME-Version: 1.0 References: <20191112130244.16630-1-vincent.whitchurch@axis.com> <20191112160855.GA22025@arrakis.emea.arm.com> <20191112180034.GB19889@willie-the-truck> <20191112182249.GB22025@arrakis.emea.arm.com> <20191113102357.GA25875@willie-the-truck> In-Reply-To: From: Linus Torvalds Date: Wed, 13 Nov 2019 08:40:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] buffer: Fix I/O error due to ARM read-after-read hazard To: Will Deacon Cc: Catalin Marinas , Vincent Whitchurch , Jens Axboe , Russell King - ARM Linux , Linux Kernel Mailing List , Linux ARM , Vincent Whitchurch , Richard Earnshaw Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 13, 2019 at 8:36 AM Linus Torvalds wrote: > > test_bit() is a very unfortunate interface, in that we actually use it > in some situations where we _really_ would want to merge reads (not > split them, but merge them). There are several cases where we do > constant test-bits on the same word, and don't care about ordering. > Things like thread flags etc. Side note: test_bit() really isn't good for locking in the first place. The fact that the buffer heads use it for that is very non-optimal indeed. Particularly for testing something like "is this buffer uptodate", it should be a "smp_load_acquire()", not a test_bit(). And READ_ONCE() doesn't really help. So in many ways it would be much better to make the buffer head stuff use proper ordered accesses. But I suspect nobody is going to ever want to go through that pain for a legacy thing, so the papering it over with READ_ONCE() and a ugly ARM hw erratum hack is probably the best we'll do.. Linus From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52E97C432C3 for ; Wed, 13 Nov 2019 16:57:01 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E0234206D5 for ; Wed, 13 Nov 2019 16:56:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HeHYp+dz"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hBBa3CeK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E0234206D5 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RpvbJE72/uF27A4tcTVIlnaLPObSUCwQyz7kBi+qfho=; b=HeHYp+dzjpVfbk As+8xRYSK1egk8DRvjTkNvbflXPnBBMleWabFP1A61tcTeP1YBkawJj/V+zsH/Je4o8JpZbdsjkJK SRMiYmAtL06KzIPPp37Wjkq/1VniUyroSrTvVHDr8qSPllpTHr1RK/q9ZJkVvFLPow2jcV/QUZ6WV GVH5QBLPBA+7bgNTsJD2S9cBFhVImzS94sCLa7xwefD2xMlZrEQWtt1MO9Ei1FBuoqRQOI0DvmUca /qD6LyMtlVtXJI4iyEAC1WpfIf5ncSQWi8I3ohszo7FG4zBSkuKZ1LDzsC+vbp1sbHST9Sq2f8Dbp 65/8FNj293kdl8bMrLNg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUvhZ-0001eB-2N; Wed, 13 Nov 2019 16:41:05 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUvhW-0001d1-Dx for linux-arm-kernel@lists.infradead.org; Wed, 13 Nov 2019 16:41:03 +0000 Received: by mail-lj1-x243.google.com with SMTP id d5so3333942ljl.4 for ; Wed, 13 Nov 2019 08:41:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IXJjwxWVC55yLVrTrqMlfhMslA2YmSoPCmuWxQ9Z1yA=; b=hBBa3CeKyqP0PPhoeL6NBNaKCWmnnCm42FJMebd8vhB9frKHZbx/LVLxNigeYeeSyf Tr9US9KNUDjInwfvRwXHyNa4DeqDgvfhgO7Bbq+xFPMkcEXTZsq5M/y0tPhks9KaQJcN CurISmPdkfK1RyWNlXatFqKzg9omOPzuFCsrk= 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; bh=IXJjwxWVC55yLVrTrqMlfhMslA2YmSoPCmuWxQ9Z1yA=; b=h0EBtQ3XiWfh19VMzfMn2rKNQpOJqOXm8RBSsigjvVkyzBZvAXm3oxY2NXPcr5r0Y0 aYqGe6jyzFjlYJfdPW2dTrnwl6IQKZlWLP+CX13lKnmNyDUfJnPMmM6w4vRe4uaTWzLn nDLUuHUGiuyyl0Q6dNyksk8MZEhYjKOMFA7Vl93EiJCyNvS0guqCLnuGqtNBYsuWQy6F c9om3ALsg+nXdvPaFpLRliOub6VpUXjaIfjgwww7xrrbk/btnjywcG3P8EUOHQ1NuZAH Q8USD2DcRqfYi063P3/LKK6RY7MjiyWHMf6E0mOO9o22t+JMAGDTfqQlNIpCBJu0VFcQ WjRg== X-Gm-Message-State: APjAAAWM5GyedvAA2WyuAR7FauciJkjJI5z0bSQG+jcM6AQQD1zSxErX BKVNP4cb6Cllgd8F3Wy5Ky+NxEwLBbA= X-Google-Smtp-Source: APXvYqy8rANygS8JRXzIfh1CI3vKiZy1uzFdlo9x80TDZS5ihCCFmlta8ulZnmnzTnsqgvIFP2QvNw== X-Received: by 2002:a05:651c:20a:: with SMTP id y10mr3327488ljn.76.1573663258742; Wed, 13 Nov 2019 08:40:58 -0800 (PST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com. [209.85.167.41]) by smtp.gmail.com with ESMTPSA id w21sm1086664ljg.91.2019.11.13.08.40.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 Nov 2019 08:40:57 -0800 (PST) Received: by mail-lf1-f41.google.com with SMTP id y186so2523014lfa.1 for ; Wed, 13 Nov 2019 08:40:57 -0800 (PST) X-Received: by 2002:ac2:5bca:: with SMTP id u10mr3466591lfn.134.1573663257105; Wed, 13 Nov 2019 08:40:57 -0800 (PST) MIME-Version: 1.0 References: <20191112130244.16630-1-vincent.whitchurch@axis.com> <20191112160855.GA22025@arrakis.emea.arm.com> <20191112180034.GB19889@willie-the-truck> <20191112182249.GB22025@arrakis.emea.arm.com> <20191113102357.GA25875@willie-the-truck> In-Reply-To: From: Linus Torvalds Date: Wed, 13 Nov 2019 08:40:41 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] buffer: Fix I/O error due to ARM read-after-read hazard To: Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191113_084102_468716_02F9F472 X-CRM114-Status: GOOD ( 13.49 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jens Axboe , Richard Earnshaw , Vincent Whitchurch , Catalin Marinas , Vincent Whitchurch , Russell King - ARM Linux , Linux Kernel Mailing List , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Nov 13, 2019 at 8:36 AM Linus Torvalds wrote: > > test_bit() is a very unfortunate interface, in that we actually use it > in some situations where we _really_ would want to merge reads (not > split them, but merge them). There are several cases where we do > constant test-bits on the same word, and don't care about ordering. > Things like thread flags etc. Side note: test_bit() really isn't good for locking in the first place. The fact that the buffer heads use it for that is very non-optimal indeed. Particularly for testing something like "is this buffer uptodate", it should be a "smp_load_acquire()", not a test_bit(). And READ_ONCE() doesn't really help. So in many ways it would be much better to make the buffer head stuff use proper ordered accesses. But I suspect nobody is going to ever want to go through that pain for a legacy thing, so the papering it over with READ_ONCE() and a ugly ARM hw erratum hack is probably the best we'll do.. Linus _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel