Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp57220pxh; Thu, 7 Apr 2022 13:52:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnAX6ioA8Un4W09T1dAXV/SW+v4DS9Pz1/gJ3lLVoEFI60Viy9CNgaa2LJnOZoHLxdlc6o X-Received: by 2002:a17:902:e547:b0:156:c4e4:c0c7 with SMTP id n7-20020a170902e54700b00156c4e4c0c7mr15618273plf.61.1649364770467; Thu, 07 Apr 2022 13:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649364770; cv=none; d=google.com; s=arc-20160816; b=BLOS33bTWlqFD1kXN4iLfP1UUa9OYcotDXt1xOix6qvcV5idMmkpheMmLznKMCLCQx m6AdFQbbIit9AmjSigfm93E0Lni2I+BYKjajExAVrDHthgHRxpQbWfTtS2DYF8V4aOCz 3/N8pGvA/U9ox+0LY+8GjVRoo4W25r2UvYGNq+q2uJT6IYRgjeA3CUqsdlQAXmAWU3DC +jmF7m0xtoAtohsIAKvdWT+E9TDYirQpgh82c7gucZeYNij7DRAWb8RBLvbqdXukc1NF FAy8U56Gz3rv5ej02ip0Ehrh3qthmKbgB6+T77awUy+z6gWHeL75UREShpmteRRoJ9YN vUgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=e4vDhMzvy3YOkQ9zBYte/XQ0KAaKC9sgRay0l4XcsQ4=; b=nuMM9+Q/dflEEYgS/Z//K6/6WZM7h0R9tDTrvwSjbTLEQKMtA0fnGBU3AC6N6eddEk XfQuyFn4X7Djbh5pVhEoC/tMM5Ontbv9zTuCBazgbUYUJk5wMG2+UnZh6boySXH+UPzF /xf+iTtFnm8rxciuHUyLu9iZL3q8yGK8PkilD13q9uOMYmGhAaWAxzm268Y5XZyLWWbQ yQ8Pwmljakf0pSB1y9UMmddKhQJOVv6ZqjMaktUlJJSa7I1cVpA1I62dYSVaRgS+ej/L B81gW5G9W2uNYws3doJ6qphYlHMExnBraofSZvOH2LxHJJwHQ6BH/MvxpunbjIJ92vRE os3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Bqewqm4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l1-20020a632501000000b00399632a476esi8826272pgl.686.2022.04.07.13.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:52:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Bqewqm4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EB53D3D48C8; Thu, 7 Apr 2022 12:57:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240131AbiDGM3I (ORCPT + 99 others); Thu, 7 Apr 2022 08:29:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240927AbiDGM3E (ORCPT ); Thu, 7 Apr 2022 08:29:04 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FD49527C0 for ; Thu, 7 Apr 2022 05:27:02 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id h19so5316802pfv.1 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=jmsLhe015ofVkBJAI0//TWVO1/Pzy1C69sjpPVXPLOSuYOUOFtYhW2PULUARmVsAZQ vd0YW274R8QGHAPMPJzcIkzm1PK4YH8sgxWVn73RclUD+/vAYkGneBKfVFOFnDBX1Zqw m4gP3dGO1PK9eGVhgyYA+xcjsb3P+h5RJD2XEaQWrLaKUlEtzWh20/6s+yqlDkQ7PUDR 2Ewt75SFAxnFyUfiOqpOimNs5BAlci+5oU64Mx2bHQUJM0e8ZcR5B/Qh3/CDEUkznYfN GZNgG/tbndjtHEQUljYqVjbj+4cqJ6yP60wl1SGWf9tBQzA0hWNXhG7LvB6ZkQoheTTX k3Cg== X-Gm-Message-State: AOAM5330vV+iTN2AREy+EY7jZpx2LDhe05UNh6BYRd1crLfw6wgvumbp c7CyPh8puFyhMGHVMiqFCKo= 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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