From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Axboe Subject: Re: [PATCH] block: use 32-bit blk_status_t on Alpha Date: Wed, 21 Mar 2018 11:02:06 -0600 Message-ID: <9cd0ef78-68e0-2c08-ca37-775c931fa159@kernel.dk> References: <502b7c1e-a95c-ff8d-64cd-9cbdd275fa1d@kernel.dk> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=CsRgHKhRuWzl0hgfPRyFtf5KQ6B44DahFAVrPZS0mTY=; b=e1TMbHcNOSJLshS8u2f6oz0wPvXqjuo09a0s5t/nMdHdpC4n2gJDMitf4AI7co9tG1 yDInjFQC+x6QXzMTDv8BliCcH8YNYjXGv0Gj9y3+hOtToWHmu2F9QqiG1f7uNCarKVmJ YxJM9XOijHq3+pkqJJdULUK/qzD5jUpi0BaSDuosBmi6vvzYLRd+7Yv5Hn2pZcn8Legi /tNbXnd3PhKmEBVwXdl6D9XR8ymfRNHLxaeYF7YidT0nXWX5lDVZczVSd320MRoHElfr 6nYRZDgnd49xiHhDhY/ZEKxEbviqrEKE2ZGcoSy+bQcpBHE6juIXrwE9jL8gBJIAD9ad HGgA== In-Reply-To: Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" To: Mikulas Patocka Cc: Richard Henderson , Ivan Kokshaysky , Matt Turner , Mike Snitzer , linux-block@vger.kernel.org, dm-devel@redhat.com, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org On 3/21/18 11:00 AM, Mikulas Patocka wrote: > > > On Wed, 21 Mar 2018, Jens Axboe wrote: > >> On 3/21/18 10:42 AM, Mikulas Patocka wrote: >>> Early alpha processors cannot write a single byte or word; they read 8 >>> bytes, modify the value in registers and write back 8 bytes. >>> >>> The type blk_status_t is defined as one byte, it is often written >>> asynchronously by I/O completion routines, this asynchronous modification >>> can corrupt content of nearby bytes if these nearby bytes can be written >>> simultaneously by another CPU. >>> >>> - one example of such corruption is the structure dm_io where >>> "blk_status_t status" is written by an asynchronous completion routine >>> and "atomic_t io_count" is modified synchronously >>> - another example is the structure dm_buffer where "unsigned hold_count" >>> is modified synchronously from process context and "blk_status_t >>> write_error" is modified asynchronously from bio completion routine >>> >>> This patch fixes the bug by changing the type blk_status_t to 32 bits if >>> we are on Alpha and if we are compiling for a processor that doesn't have >>> the byte-word-extension. >> >> That's nasty. Is alpha the only problematic arch here? > > Yes. All the other architectures supported by Linux have byte writes. > >> As to the patch in question, normally I'd just say we should make it >> unconditionally u32. But we pack so nicely in the bio, and I don't think >> the bio itself has this issue as the rest of the members that share this >> word are all set before the bio is submitted. But callers embedding >> the status var in other structures don't necessarily have that >> guarantee, as your dm examples show. >> >> -- >> Jens Axboe > > Keeping blk_status_t 8-bit for most architectures will save a few bytes in > some of device mapper structures. And more importantly, it won't screw up the bio layout, I'm somewhat more concerned about that than random driver structures. If alpha is the odd one out here, then I think your patch is fine as-is. -- Jens Axboe