Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp976431pxb; Fri, 22 Apr 2022 15:46:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyO7DgyPpf0pn5FHLSaQ1flmtUubLHUXAh2KNhscnS3ZKQUm7hJHawXlUSsKKpeJYQ815eM X-Received: by 2002:a05:6870:6006:b0:e5:e6f1:5f2a with SMTP id t6-20020a056870600600b000e5e6f15f2amr2981412oaa.160.1650667574606; Fri, 22 Apr 2022 15:46:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650667574; cv=none; d=google.com; s=arc-20160816; b=c2otHvOgBMfRd2cZbH7kHxNw3XMBNFPRnGs9YkK1/wLCexmj5mHKjvMXZMvRnB5xBC hANSFgX+HWLfo/B2LkrhMAjjxA96z3fwYPki7xVl8dFFPzGE17osNKq6xYmUwO6TZ0cc FU8KGLMISQeyHLiadb+tujeo1kXc7x3z0aulnu7WPgmCy423bAqJ920BKvZLbUhw8OsE 68jS07+hPC2MUMmUlS4vzh9QWgydPTPFfL/NP5FcUpoOYjaPKvw21fAh2KSw/DmPPqYK eEXA3ufE5X2Y9+pVuU/paogVWaMmlY2YjX/4ljZ82+CGlVuBdhzPa75enKMYij0cmBOr ltAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=Qa8i7wrPrLxRucy9LVsaquhTy4IME0vooz5lk1Is9QymqNNR2e6W/TtT7jPutCM/2O Y91EooXD/UexhxznCHeyk2BE8Lmg1s68gYLHdCZsnilr8F2tk8PIBMu8rqIY/c1egJOP omRi8YqF+7jzDndFn1vAVxN00nWjFhOOIk5CCOdZjY1VQXq7ifPJKTWlNhu6ERyPRmCG 9T6K3d9i+fpmsdfOyOHYR4EbVqMsN6Ly7HTWhWUZzoCboab1TdQBU5R3UYuQBPbR4D+1 C7I9ZMx04CMPzhzocU2rqtcBO4rlpScJi7e8721qWzSbB2TQHyGfKBWvPGNluZntAGcq wTMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EXx39caV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n23-20020a056870559700b000e2af2dc365si5230189oao.34.2022.04.22.15.46.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:46:14 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=EXx39caV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78FFA1C2496; Fri, 22 Apr 2022 13:34:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231696AbiDVRsR (ORCPT + 99 others); Fri, 22 Apr 2022 13:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234421AbiDVRru (ORCPT ); Fri, 22 Apr 2022 13:47:50 -0400 Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com [209.85.217.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA930DF0 for ; Fri, 22 Apr 2022 10:44:55 -0700 (PDT) Received: by mail-vs1-f53.google.com with SMTP id v133so8089631vsv.7 for ; Fri, 22 Apr 2022 10:44:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=EXx39caVzrDVxXmzeFHNJ/VpA0Vf9nhcaUODJblSmmzfQCqSIclIq3k/72jlhOe7xU mxS7DiSX8wD9WeA0yp1NbvWAVdMNUxuU4gaIzQh8JJ8fyCnu0l5lwI1ZT5DQmvo3o/GL giMkmhaOpRIcD3Pxc/WQ0G8uNs49u4slv1VqwwKj8ILUDMpg4P2Gy0pNs+Rl8wxHkt2u AaT3fwMdeZX7l84TVbveI7BoObbfwdo20kpJqU2PgPdBHaSHTHXSz6+BpCsCPepPwYib Pzvv+mS2caK2fXnFrZHgiNJflVFXQzaIMwIiG9huu4nfjIBK80wyF276rcBbBNxqduav T9FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1B5OLyPzDad+a9/JvoswRLL9dkqWt3XLCqj2yVlzJ3g=; b=gHUKOTnutZmbtAq4dNMcb1RbeiWakWEH1gHQ4Jc13KG6xfn5VZhN1LrdH7cLrXncW3 CKXzYEeFNkQHxBvGOdTxv5jb3JCH60yj25QgiGQBRVv+Gfgqp6WIZcfp1r226UQn6jAX OSVi0zx1h+bppfu7XgiSbncIfcj1Iq4+18AdS/RfmIXZvjm81OLdLsOFnJeO8eb6aba0 qnHxV743zD4aYXhjwpAAjmHCV+7AJqD0zmTTZAJCindmrq2EVL2wrMBrpTeDjuYhweqy 86yuMoSMJqqs6D+Zs+DjikAsenDsEQKbELZkCyjzcfwC76rBSUIeKk4PIRLMTQFdzoqI q+NQ== X-Gm-Message-State: AOAM532vtIMTBqtxqFNtldSODB9Zuce1vMJi4Z3nvXxm1zv3HnTkT+2z 2jtcjo4YhO3FAal9MgDKZJ9qa9iqTTfylm+1ovIonw== X-Received: by 2002:a05:6102:390e:b0:324:c2b1:f077 with SMTP id e14-20020a056102390e00b00324c2b1f077mr1825856vsu.67.1650649219372; Fri, 22 Apr 2022 10:40:19 -0700 (PDT) MIME-Version: 1.0 References: <20220421031738.3168157-1-pcc@google.com> In-Reply-To: From: Peter Collingbourne Date: Fri, 22 Apr 2022 10:40:08 -0700 Message-ID: Subject: Re: [PATCH] mm: make minimum slab alignment a runtime property To: Andrey Konovalov Cc: Hyeonggon Yoo <42.hyeyoo@gmail.com>, Andrew Morton , Linux ARM , Linux Memory Management List , Linux Kernel Mailing List , Vlastimil Babka , Pekka Enberg , cl@linux.org, roman.gushchin@linux.dev, Joonsoo Kim , David Rientjes , Catalin Marinas , Herbert Xu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Eric Biederman , Kees Cook Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,USER_IN_DEF_DKIM_WL 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 Fri, Apr 22, 2022 at 9:09 AM Andrey Konovalov wrote: > > On Fri, Apr 22, 2022 at 2:39 PM Hyeonggon Yoo <42.hyeyoo@gmail.com> wrote: > > > > > > kasan_hw_tags_enabled() is also false when kasan is just not initialized yet. > > > > What about writing a new helper something like kasan_is_disabled() > > > > instead? > > > > > > The decision of whether to enable KASAN is made early, before the slab > > > allocator is initialized (start_kernel -> smp_prepare_boot_cpu -> > > > kasan_init_hw_tags vs start_kernel -> mm_init -> kmem_cache_init). If > > > you think about it, this needs to be the case for KASAN to operate > > > correctly because it influences the behavior of the slab allocator via > > > the kasan_*poison* hooks. So I don't think we can end up calling this > > > function before then. > > > > Sounds not bad. I wanted to make sure the value of arch_slab_minaligned() > > is not changed during its execution. > > > > Just some part of me thought something like this would be more > > intuitive/robust. > > > > if (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF) > > return MTE_GRANULE_SIZE; > > else > > return __alignof__(unsigned long long); > > Hi Hyeonggon, > > We could add and use kasan_hw_rags_requested(), which would return > (systems_supports_mte() && kasan_arg != KASAN_ARG_OFF). > > However, I'm not sure we will get a fully static behavior: > systems_supports_mte() also only starts returning proper result at > some point during CPU bring-up if I'm not mistaken. > > Thanks! Yes, either way we are going to rely on something that hasn't obviously been initialized yet, so I think we should stick with what I have since it's used by the rest of the KASAN code as well. Peter