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 X-Spam-Level: X-Spam-Status: No, score=-23.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A28DC04FF3 for ; Mon, 24 May 2021 10:36:50 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9221606A5 for ; Mon, 24 May 2021 10:36:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9221606A5 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A220C940069; Mon, 24 May 2021 06:36:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A450940055; Mon, 24 May 2021 06:36:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4C172940069; Mon, 24 May 2021 06:36:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 093B2940055 for ; Mon, 24 May 2021 06:36:47 -0400 (EDT) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7B2D1181AEF30 for ; Mon, 24 May 2021 10:36:47 +0000 (UTC) X-FDA: 78175771254.10.0E9A092 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by imf12.hostedemail.com (Postfix) with ESMTP id 07191130 for ; Mon, 24 May 2021 10:36:39 +0000 (UTC) Received: by mail-oi1-f180.google.com with SMTP id s19so26645371oic.7 for ; Mon, 24 May 2021 03:36:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OyogGDxMaGSBrj2rkEP+jK8JOL+4OXbDVcsd7RbbjgQ=; b=vO8TRdchq8qlXFP7kNIZKyborERcCPCFxcRJlmVAg91ZhBc+M/OlVcyjenZaivhTHq SFT99XA7iNxm5biJlXDD6SDFMlUDP4f+KFEVn43PqGQyRm/xeH3pTNwqy2XaJPlQdJMs Wo3I/Ob/uXt+TrLVe1h7dpHeOsUo8sDpK+1yhlTf3UCuW/GzVoABNtORkiLQL98hJWLU ZPUOvhlgokNhXjOlFavc8zrbqCUyohZECH3qe8YwsRgKibc53g4FQOoC5ds1BJznXRJQ P2qvqB+EzJ5NnOH6CRr/FCln8RaGoqcqdM4/E+3de9AN3hMDF+gWMRuNDLir7A04Gk11 ITKA== 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=OyogGDxMaGSBrj2rkEP+jK8JOL+4OXbDVcsd7RbbjgQ=; b=ZoqBKPny//oJV48wdkTIcfTwohFu+/jz6rYGappiP2FAAovRjjWlnuKPwbiOb8g4MF Q+Vxr7gvVN0brnotbDAk/uucOVAfudJe7Cbt5ILtK/ziCbpmkvvrONtfHqf7aTYx2ipq 0VPfHcDe9ozEm4s4iGK1oZ2nqY7r+UwkWDnThAyg4ZbbRgpGkAqK+/PWQFyjvSblCxI6 YnCh0b9FR62mWPwbs65aFsmS8xtIyfZh3fPX8uu0JsScLnz4LNDLJu8Z171DxwInx7sV fGoq85I27JLHMGGwoPZbbBtWG8k+uiyC3QKsVcpkBFVdDHY8pHmFfnhjnWWXEGpgfrYW HXMg== X-Gm-Message-State: AOAM530JtMEW4F+sFQFP/0ESJXcF78Z+hkasIo4nBoBdbDAEbNw8Lhgi rhXxfB4xY/k1j8Hnj8C444DQlUo3lIFUhdD5RKXsRA== X-Google-Smtp-Source: ABdhPJxTHFDXkF0sGbpwKQ/wGAzN9+c/BhxVAg382Xrdc+7foZ+2Jc5h0xV9kkBUR2lsvZI4bw9Advoi1aORJHu1tpk= X-Received: by 2002:a05:6808:10d4:: with SMTP id s20mr10530580ois.70.1621852606335; Mon, 24 May 2021 03:36:46 -0700 (PDT) MIME-Version: 1.0 References: <20210524172433.015b3b6b@xhacker.debian> <20210524172529.3d23c3e7@xhacker.debian> In-Reply-To: <20210524172529.3d23c3e7@xhacker.debian> From: Marco Elver Date: Mon, 24 May 2021 12:36:34 +0200 Message-ID: Subject: Re: [PATCH 1/2] kfence: allow providing __kfence_pool in arch specific way To: Jisheng Zhang Cc: Catalin Marinas , Will Deacon , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Linux ARM , LKML , kasan-dev , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=google.com header.s=20161025 header.b=vO8TRdch; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf12.hostedemail.com: domain of elver@google.com designates 209.85.167.180 as permitted sender) smtp.mailfrom=elver@google.com X-Stat-Signature: 97k91gnnpjnjuxbgi1woreqausyn47co X-Rspamd-Queue-Id: 07191130 X-Rspamd-Server: rspam02 X-HE-Tag: 1621852599-672381 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, 24 May 2021 at 11:26, Jisheng Zhang wrote: > Some architectures may want to allocate the __kfence_pool differently > for example, allocate the __kfence_pool earlier before paging_init(). > We also delay the memset() to kfence_init_pool(). > > Signed-off-by: Jisheng Zhang > --- > mm/kfence/core.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/mm/kfence/core.c b/mm/kfence/core.c > index e18fbbd5d9b4..65f0210edb65 100644 > --- a/mm/kfence/core.c > +++ b/mm/kfence/core.c > @@ -430,6 +430,8 @@ static bool __init kfence_init_pool(void) > if (!__kfence_pool) > return false; > > + memset(__kfence_pool, 0, KFENCE_POOL_SIZE); > + Use memzero_explicit(). Also, for the arm64 case, is delaying the zeroing relevant? You still call kfence_alloc_pool() in patch 2/2, and zeroing it on memblock_alloc() is not wrong, correct? Essentially if there's not going to be any benefit to us doing the zeroing ourselves, I'd simply leave it as-is and keep using memblock_alloc(). And if there's some odd architecture that doesn't even want to use kfence_alloc_pool(), they could just zero the memory themselves. But we really should use kfence_alloc_pool(), because otherwise it'll just become unmaintainable if on changes to kfence_alloc_pool() we have to go and find other special architectures that don't use it and adjust them, too. Thanks, -- Marco > if (!arch_kfence_init_pool()) > goto err; > > @@ -645,10 +647,10 @@ static DECLARE_DELAYED_WORK(kfence_timer, toggle_allocation_gate); > > void __init kfence_alloc_pool(void) > { > - if (!kfence_sample_interval) > + if (!kfence_sample_interval || __kfence_pool) > return; > > - __kfence_pool = memblock_alloc(KFENCE_POOL_SIZE, PAGE_SIZE); > + __kfence_pool = memblock_alloc_raw(KFENCE_POOL_SIZE, PAGE_SIZE); > > if (!__kfence_pool) > pr_err("failed to allocate pool\n"); > -- > 2.31.0 >