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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7D479C433EF for ; Thu, 7 Apr 2022 12:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gegT+knhcXVlcqPdYIxJ8IxgruImPFb71WbvrbbbkUw=; b=Eds5s5kty3nsF9 jlTgbf+JgMhw35+h9sQ1VTi7gPaQWeYpDtqTVA4ztAU6fKyDj9NIek1AU/jH1JDdcg0z1I5elqde6 aDSVJ/RHvaaNlD5ujgpI0+XnD1DbfQW7S9fkm2pSSq2IbDsq7U9iwqGIcTM6529tDUFxrrKLe+5jE MspOpiUMeL1g/9AN41K1bp9hyljMO57rClOqNdNnzQzhTLWvOzzIKbdHl15Pc5Enim+eH3rLHA1c9 TKKsu/t+7o7O68wQE4ijPLQFcpA+jB0V0mPF33VNmSWuQT6QkNkW6Np91qK313K1wY1662WNt6FU9 G1nIjB/DlehQOgQkncIQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncREF-00Bqj3-3X; Thu, 07 Apr 2022 12:27:11 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ncRE9-00Bqgs-7Y for linux-arm-kernel@lists.infradead.org; Thu, 07 Apr 2022 12:27:07 +0000 Received: by mail-pf1-x432.google.com with SMTP id w7so5266469pfu.11 for ; Thu, 07 Apr 2022 05:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=e4vDhMzvy3YOkQ9zBYte/XQ0KAaKC9sgRay0l4XcsQ4=; b=Bqewqm4sEfX65AFnOPS0H7hoOh025r+5pYa8XlINcT2djuUhGa6YdGxA9fbeqTDjyg KNtHn/NyR4r8d1UtL+8HCu4ZpWyiP9m8nMNO03pun9+9VycNNhbAm+kV+OdaSmYBIG/2 hUS/5hyIarlKQ8/ItJ8HSwmZvo+skzd3cQqErxhDDrFnII7RLenCkb+HhEO7SUE8qZy7 a/KoPg3mdOYv/v1mngtLvR7tSu5EKLzMuaNP+yUg78pVzp8wra7ZbIL5ZZAhfuPOnJd9 n09rOzspRyLAXyB4z8aS6blEAkmGjgvVil66LuisUz6u+DUJA8sR4XtiZgfvc5dGa4KV Q5oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=e4vDhMzvy3YOkQ9zBYte/XQ0KAaKC9sgRay0l4XcsQ4=; b=NfF3topT0eYVOXHxjafadnTJmhA1huszAV0/vD0O845WzwlS+OEHWZo3jhBJeZtjak JfOkoLm/0tajAQSckmqWnfVQdhZMO1badcNS9LrPtz1fTlq19ZCkp98oefr/HkJ8T1GH +R+YN5BiOk3KAkckOQCJ8SUZmc+PxNYj9ZehOf94qrcs28dCNnJXzH01fvSWsrelEuFc YIP8mAx3K2GcnF7MG6xTcK18NkV6jM7VB8Yrn62yrLKDkEpImyFZZ4mFBnQFFdX1s4bc RGD9oAfUNQvIzzBHVD6PkAXPh3U+aRMJJP+dMP9ze8UxnDHqfvLf1d7LtV+7iN1NTvUI Ed+A== X-Gm-Message-State: AOAM533Tlpod60SAll4ap0V6GyXlCcN0nMMPkIi3fd2PfTyXgytbHyvV WsAHMZgvgrE/9TZG0HMtLLQ= X-Google-Smtp-Source: ABdhPJwOlATfxqxS2ks4E6hH4T/LM8RgkhDLs8dUgp/0TaEV149xG1yRI4wgWT+SoUXPa+Z/j0poHw== X-Received: by 2002:a63:5317:0:b0:399:58e9:882b with SMTP id h23-20020a635317000000b0039958e9882bmr11120930pgb.306.1649334422001; Thu, 07 Apr 2022 05:27:02 -0700 (PDT) Received: from hyeyoo ([114.29.24.243]) by smtp.gmail.com with ESMTPSA id ay9-20020a056a00300900b004fae1346aa1sm20786357pfb.122.2022.04.07.05.26.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 05:27:00 -0700 (PDT) Date: Thu, 7 Apr 2022 21:26:53 +0900 From: Hyeonggon Yoo <42.hyeyoo@gmail.com> To: Catalin Marinas Cc: Will Deacon , Marc Zyngier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 08/10] mm/slab: Allow dynamic kmalloc() minimum alignment Message-ID: References: <20220405135758.774016-1-catalin.marinas@arm.com> <20220405135758.774016-9-catalin.marinas@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220407_052705_333111_32D34B1D X-CRM114-Status: GOOD ( 40.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Apr 07, 2022 at 10:35:04AM +0100, Catalin Marinas wrote: > On Thu, Apr 07, 2022 at 06:18:16PM +0900, Hyeonggon Yoo wrote: > > On Thu, Apr 07, 2022 at 09:50:23AM +0100, Catalin Marinas wrote: > > > On Thu, Apr 07, 2022 at 03:46:37AM +0000, Hyeonggon Yoo wrote: > > > > On Tue, Apr 05, 2022 at 02:57:56PM +0100, Catalin Marinas wrote: > > > > > --- a/mm/slab_common.c > > > > > +++ b/mm/slab_common.c > > > > > @@ -838,9 +838,18 @@ void __init setup_kmalloc_cache_index_table(void) > > > > > } > > > > > } > > > > > > > > > > -static void __init > > > > > +unsigned int __weak arch_kmalloc_minalign(void) > > > > > +{ > > > > > + return ARCH_KMALLOC_MINALIGN; > > > > > +} > > > > > + > > > > > > > > As ARCH_KMALLOC_ALIGN and arch_kmalloc_minalign() may not be same after > > > > patch 10, I think s/ARCH_KMALLOC_ALIGN/arch_kmalloc_minalign/g > > > > for every user of it would be more correct? > > > > > > Not if the code currently using ARCH_KMALLOC_MINALIGN needs a constant. > > > Yes, there probably are a few places where the code can cope with a > > > dynamic arch_kmalloc_minalign() but there are two other cases where a > > > constant is needed: > > > > > > 1. As a BUILD_BUG check because the code is storing some flags in the > > > bottom bits of a pointer. A smaller ARCH_KMALLOC_MINALIGN works just > > > fine here. > > > > > > 2. As a static alignment for DMA requirements. That's where the newly > > > exposed ARCH_DMA_MINALIGN should be used. > > > > > > Note that this series doesn't make the situation any worse than before > > > since ARCH_DMA_MINALIGN stays at 128 bytes for arm64. Current users can > > > evolve to use a dynamic alignment in future patches. My main aim with > > > this series is to be able to create kmalloc-64 caches on arm64. > > > > AFAIK there are bunch of drivers that directly calls kmalloc(). > > Well, lots of drivers call kmalloc() ;). > > > It becomes tricky when e.g.) a driver allocates just 32 bytes, > > but architecture requires it to be 128-byte aligned. > > That's the current behaviour, a 32 byte allocation would return an > object from kmalloc-128. I want to reduce this to at least kmalloc-64 > (or smaller) if the CPU/SoC allows it. Yeah I agree the change is worth :) Thanks for the work. > > That's why everything allocated from kmalloc() need to be aligned in > > ARCH_DMA_MINALIGN. > > I don't get your conclusion here. Would you mind explaining? What I wanted to say was that, why ARCH_DMA_MINALIGN should be different from ARCH_KMALLOC_MINALIGN. I thought the two were basically same thing. Instead of decoupling them, I thought just decreasing them in runtime makes more sense. > > So I'm yet skeptical on decoupling ARCH_DMA/KMALLOC_MINALIGN. Instead > > of decoupling it, I'm more into dynamically decreasing it. > > The reason for decoupling is mostly that there are some static uses of > ARCH_KMALLOC_MINALIGN as per point 1 above. The other is the > __assume_kmalloc_alignment attribute. We shouldn't have such assumed > alignment larger than what a dynamic kmalloc() would return. To me it > makes a lot more sense for ARCH_KMALLOC_MINALIGN to be the minimum > guaranteed in a kernel build but kmalloc() returning a larger alignment > at run-time than the other way around. But yeah, considering the problems you mentioned, it seems unavoidable to decouple them. Thank you for explanation and I will review slab part soon. > Thanks. > > -- > Catalin -- Thanks, Hyeonggon _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel