Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2659187imm; Mon, 24 Sep 2018 07:59:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYW02OU54YwLXi8RocnrmCMiCbvKNNNgY9QDI2OBmZC3iOqAkfCY8M3ArdDRV2hhnwhcdVf X-Received: by 2002:a62:2b50:: with SMTP id r77-v6mr10690789pfr.51.1537801157136; Mon, 24 Sep 2018 07:59:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537801157; cv=none; d=google.com; s=arc-20160816; b=G9SEJYWRIOj+xHDtlhjeIiw1avPtVcXBfLemkXLV/pLF6Ts8QZHPsI439tD1NLRQi5 nxV+UWUlU34mrIRsOXJePKMv6rt3EPDRHjFcI0JWbMULxOYZ4YvMsJ+7FAR466DB+fD2 IkjVASAbM1wZ+RKLlvxhJNqUxvcRj5hRccYDPNTe0oWDaE7nOIqRYSM0rDY8JGd5YgCp +CqB4dERrTSZw5xoPW9OXn7RJ4KrlOGiAVlneuRPDo2Nh/3JpIxxp5Bn7RiiUnxWr5S1 scy3cfnDL1HxCVaLIlpbYco0vJ8zpW/GJ0M96u6v/HV4KhrgU7UH10FEfraHQtrqaR3k LEbw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=BEtXEmV+colSyj+N+YYwVyKrduG6ry/YpPcHyo7hjOw=; b=kxKihAzSJH7OD84e783O2It+9hX4UOKLIGMXcBauZcaRyhMJA7sHS3Up/uqqFSR17u GBqEIVDasRR7e/5Atwj6LobhUXfycTg5yp++4EklO8OPnnJUilrvAa+RwGPS8nZU9oLM WgfJN1E9N1IVveBH2CRw8AA6AS+6B9JB7EhUWKV+qOqYuA6xz9ioo3wg24xonE13c6AE 0itV2yEIAeirfdrfh9jhVUyALL8o6m00QCLuQnFppCQ6fc4TCI7CwOXbUYXI0EMOLg2G k9fk3+Yro+YK+ok3AUSnW9pXqDrLoJ8TOXAI7zCoH+MTFMi6NRzJ8weGDozfNbjja7br du7A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19-v6si843074pfm.152.2018.09.24.07.59.01; Mon, 24 Sep 2018 07:59:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728895AbeIXUVm (ORCPT + 99 others); Mon, 24 Sep 2018 16:21:42 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46869 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbeIXUVm (ORCPT ); Mon, 24 Sep 2018 16:21:42 -0400 Received: by mail-pl1-f193.google.com with SMTP id v19-v6so1511170ply.13; Mon, 24 Sep 2018 07:19:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=BEtXEmV+colSyj+N+YYwVyKrduG6ry/YpPcHyo7hjOw=; b=Mm2YWCUQMfHsVd7KJwsSQUqu/eIdz1B0/4gmh11DjKeu8au76f9j0dPBuRlkbrGaJ0 E9dCZ6U6RmRL9+vCsWmKVDB7vn7jkPwlhVgTd/5yEqsN7O9IKfylNsoIYUFVyq+L+Qtf RpE002BB8lH44XPrVm2X1DC2N6/YquUk4k1Vn7iCOVGXzKInE4PHVDsznLcSrC2UFItJ I1N1abKLzlNDTrmZn/IIMUMJz0KMbydjHDdIuL1SXPU+FAVzl4waMJcQxP+AtjCHtWNv WyDgUwU7qfbUirucGdMtDa4b+1XNWkPpnZaujEkCj3qLxCyN7ualUtR7SWeNbNlOxsQj krFA== X-Gm-Message-State: ABuFfog3ymhM7daCGTVdRjROFyKOjkWDp9pMJm755f2N7ab6ENWAOzx5 U2PKDDk8/4NonGmW0Rr58zo= X-Received: by 2002:a17:902:34a:: with SMTP id 68-v6mr11008058pld.39.1537798759652; Mon, 24 Sep 2018 07:19:19 -0700 (PDT) Received: from asus.site ([2601:647:4601:42b4:3842:3e31:3bb6:cf62]) by smtp.googlemail.com with ESMTPSA id f62-v6sm49502757pfg.74.2018.09.24.07.19.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Sep 2018 07:19:18 -0700 (PDT) Subject: Re: block: DMA alignment of IO buffer allocated from slab To: Andrey Ryabinin , Ming Lei , Vitaly Kuznetsov Cc: Christoph Hellwig , Ming Lei , linux-block , linux-mm , Linux FS Devel , "open list:XFS FILESYSTEM" , Dave Chinner , Linux Kernel Mailing List , Jens Axboe , Christoph Lameter , Linus Torvalds , Greg Kroah-Hartman References: <20180920063129.GB12913@lst.de> <87h8ij0zot.fsf@vitty.brq.redhat.com> <20180923224206.GA13618@ming.t460p> <38c03920-0fd0-0a39-2a6e-70cd8cb4ef34@virtuozzo.com> From: Bart Van Assche Message-ID: <20a20568-5089-541d-3cee-546e549a0bc8@acm.org> Date: Mon, 24 Sep 2018 07:19:17 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <38c03920-0fd0-0a39-2a6e-70cd8cb4ef34@virtuozzo.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/24/18 2:46 AM, Andrey Ryabinin wrote: > On 09/24/2018 01:42 AM, Ming Lei wrote: >> On Fri, Sep 21, 2018 at 03:04:18PM +0200, Vitaly Kuznetsov wrote: >>> Christoph Hellwig writes: >>> >>>> On Wed, Sep 19, 2018 at 05:15:43PM +0800, Ming Lei wrote: >>>>> 1) does kmalloc-N slab guarantee to return N-byte aligned buffer? If >>>>> yes, is it a stable rule? >>>> >>>> This is the assumption in a lot of the kernel, so I think if somethings >>>> breaks this we are in a lot of pain. > > This assumption is not correct. And it's not correct at least from the beginning of the > git era, which is even before SLUB allocator appeared. With CONFIG_DEBUG_SLAB=y > the same as with CONFIG_SLUB_DEBUG_ON=y kmalloc return 'unaligned' objects. > The guaranteed arch-and-config-independent alignment of kmalloc() result is "sizeof(void*)". > > If objects has higher alignment requirement, the could be allocated via specifically created kmem_cache. Hello Andrey, The above confuses me. Can you explain to me why the following comment is present in include/linux/slab.h? /* * kmalloc and friends return ARCH_KMALLOC_MINALIGN aligned * pointers. kmem_cache_alloc and friends return ARCH_SLAB_MINALIGN * aligned pointers. */ Thanks, Bart.