Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1520746imm; Wed, 19 Sep 2018 21:18:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ3FYIMRlnnHdHxfaalFoDfyV+ZEDiW0da1lzXpIYytg5Vw4nZyp58/2oOlRzIFhrk61v1E X-Received: by 2002:a63:447:: with SMTP id 68-v6mr35276040pge.409.1537417113211; Wed, 19 Sep 2018 21:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537417113; cv=none; d=google.com; s=arc-20160816; b=qz6FS6lb1zJbunw8WkIpIdJt+Vp4L71EfD9EQaAq8qrnAr9/VwTwDdqMOiT0VjBsoy o8pj6SMlbyDQYh5ArXQ9aUimhBOpp7lr/Z8Nun2liM+F1/00qpFa6Uy71+DUwNTfZJzR Nidq0OcJm9Hc1fN6oYnwtjoGFqhn/cW/rskX16lwrVixJGdnUEzMMD1TQca5voAAKV9n pr0zvbHSIYbl5p5UHkIzYUYJPDxcSTDJJjgTDin6C2KbZTXD6PO7TiL6SQ52qWy8IZe6 +9+9poUUREmjSCOijeBcY/IWUHmxvHXBsZrRntDUetpCib9VA49J+BuLKt97i4o6nhm9 TL3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0+K2MGlgvBhJZwSb9104yAlKXqp+Nr5/6etFYNZhUqA=; b=K3w/+EBySoJ0ZfY5fulAoG//CXwlLxFQI7+xBKL1Lm0r5tFlIXXQGS+GQQFtYlmlDQ V6rLlk/hm7h7lBy4+k54v3rmj2N8lZ99XyPHltyaPu3FF5OFkYcigmz9jIJIGBhj6a7X GZmMvYWlO7y03yzKv/HcaJ10uAa2I8F0mGTg3vd7tO/Aq9ejkA6DRhwdHIVOYQSknD3G RhnmnHT0Xjjz4cKYWkI1eKMX2T6rhUu4XY6F2o6LTyOfkpl6HupEcIHURUWG5zi4d2dO bf+lFFni12YW73/mWlTlxCdnt4kOrfg5BF9IOz4AePPTYhUFHsrH0kNsYzTDsZCdszGY xMOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vK0TGaDy; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n19-v6si24359564pfi.360.2018.09.19.21.18.17; Wed, 19 Sep 2018 21:18:33 -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=@gmail.com header.s=20161025 header.b=vK0TGaDy; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387481AbeITJkh (ORCPT + 99 others); Thu, 20 Sep 2018 05:40:37 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:43534 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387451AbeITJkh (ORCPT ); Thu, 20 Sep 2018 05:40:37 -0400 Received: by mail-qt0-f193.google.com with SMTP id g53-v6so7243450qtg.10; Wed, 19 Sep 2018 20:59:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0+K2MGlgvBhJZwSb9104yAlKXqp+Nr5/6etFYNZhUqA=; b=vK0TGaDyKDrg9nARKDoogokG31cJ2n4IX8gOsde3JGoYukIspXXMbfLpbhMNyyy0BY Co/PZIZfbiL6PaX/wM5aImVNj8fCOqvp2mCS0zkcY4vIyokZx6UvGRhBlWPUGC8ajmY0 dkKl6dJj3TzNqUCDf//e44UHGtVjPTCCQBhm0RCCYVUy8YBTCN8He4MFAdZbfjDwmR7V TfP6DBgT66PnWGY3QDY+mHBnZ0JeMXy6gBw/OYCIQhrlP4IcG1Y3zgWI70wYMjBsF8Ig 19FBS8We0WbS5tcGK2a6c+7JGMAF5TiTHZmlI6aaoV3bLU3+0imuJ4jABIhTe/8pEdEP kvUw== 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=0+K2MGlgvBhJZwSb9104yAlKXqp+Nr5/6etFYNZhUqA=; b=WOIrAESs8nATenaA9pJ2seCVsYiEikGHckYZuf0u0XzWuUOdA0W5XdGS9SktnSZ6ME gSE3qZQEctPyEe3X8sgdJjqpvlGJ/qofAiR2ePz1S58P4g8x2XwHLNyk+ngNlSCCScns tucHDrqHDvUbTtISPDwlnEO9sZcbl3ObLXGG+pQyimVs+oRHHVIg8+xFCwDr30LLrQhN pamn0aB7ypG9lJSAbgNIKjtTjvRNRcot+Xos7ntkbxwRNddbDogW/l6WsaSzWs7Ebipy eymJReggd8l1mw3kQTkjzhtWmrDeCk3c7LIz2jdT3UAxZpbQYB3nqitQpUS5XwbGBlMV CRLA== X-Gm-Message-State: APzg51CvpA1ThFSvUYH2qXbDlDHFCbzOgbIJ07szWEVYhKmNKv0l2A9a Q04Y1efFPyCuEu1DNXxUCHnxIuSMng76SYtMAz8= X-Received: by 2002:a0c:a91a:: with SMTP id y26-v6mr26899811qva.133.1537415959781; Wed, 19 Sep 2018 20:59:19 -0700 (PDT) MIME-Version: 1.0 References: <877ejh3jv0.fsf@vitty.brq.redhat.com> <20180919100256.GD23172@ming.t460p> <8736u53fij.fsf@vitty.brq.redhat.com> <20180920012836.GA27645@ming.t460p> In-Reply-To: <20180920012836.GA27645@ming.t460p> From: Yang Shi Date: Wed, 19 Sep 2018 20:59:07 -0700 Message-ID: Subject: Re: block: DMA alignment of IO buffer allocated from slab To: ming.lei@redhat.com Cc: vkuznets@redhat.com, Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Ming Lei , linux-block@vger.kernel.org, Linux MM , linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, dchinner@redhat.com, Linux Kernel Mailing List , hch@lst.de, axboe@kernel.dk 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, Sep 19, 2018 at 6:28 PM Ming Lei wrote: > > On Wed, Sep 19, 2018 at 01:15:00PM +0200, Vitaly Kuznetsov wrote: > > Ming Lei writes: > > > > > Hi Vitaly, > > > > > > On Wed, Sep 19, 2018 at 11:41:07AM +0200, Vitaly Kuznetsov wrote: > > >> Ming Lei writes: > > >> > > >> > Hi Guys, > > >> > > > >> > Some storage controllers have DMA alignment limit, which is often set via > > >> > blk_queue_dma_alignment(), such as 512-byte alignment for IO buffer. > > >> > > >> While mostly drivers use 512-byte alignment it is not a rule of thumb, > > >> 'git grep' tell me we have: > > >> ide-cd.c with 32-byte alignment > > >> ps3disk.c and rsxx/dev.c with variable alignment. > > >> > > >> What if our block configuration consists of several devices (in raid > > >> array, for example) with different requirements, e.g. one requiring > > >> 512-byte alignment and the other requiring 256? > > > > > > 512-byte alignment is also 256-byte aligned, and the sector size is 512 byte. > > > > > > > Yes, but it doesn't work the other way around, e.g. what if some device > > has e.g. PAGE_SIZE alignment requirement (this would likely imply that > > it's sector size is also not 512 I guess)? > > Yeah, that can be true if one controller has 4k-byte sector size, also > its DMA alignment is 4K. But there shouldn't be cases in which the two > doesn't match. > > > > > > > > > From the Red Hat BZ, looks I understand this issue is only triggered when > > > KASAN is enabled, or you have figured out how to reproduce it without > > > KASAN involved? > > > > Yes, any SLUB debug triggers it (e.g. build your kernel with > > SLUB_DEBUG_ON or slub_debug= options (Red zoning, User tracking, ... - > > everything will trigger it) > > That means the slab always return 512-byte aligned buffer if the buffer > size is 512byte in case of no any slab debug options enabled. > > The question is that if it is one reliable rule in slab. If yes, any > slab debug option does violate the rule. Once slub debug (i.e. red zone) is on, it will append extra bytes to the object, so the object may look like: ----------------------------------------------------------------- | object | red zone | FP | owner track | red zone | ------------------------------------------------------------------ This is how slub debug is designed and how it works. CC to Chris Lameter who is the maintainer of SLUB. Regards, Yang > > The same is true for 4k alignment and 4k sector size. > > I think we need our MM guys to clarify this point. > > > Thanks, > Ming >