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 023CFC61DA4 for ; Wed, 15 Mar 2023 08:53:53 +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=XSpOJ9fP35YjBNX2B4RlZi4Vwum18qhaTUe5MYJfdWU=; b=LmbOLQB7m7gJbm UTMXG2RsWGHI89iDSIulRD8VJ3mdr3Mc1rKBwoEA4YEOFvKdo+ulqhqNK9l+LpwFMOXf1buKnJjMv BUHBtcdp0T2CXOCU13cT1JtH1CFhgZEkglxa8wJuD/ISnGXkWkKHI7JniYaGo8qMlNj8Odia4U6LP 46l2pqNrNT8wTOa2YK9bd9vvKEtsGjjjA+VnABNwpz06y2viokQkFW9p6oS0e55an5X4VtcOxBjDY fo4YALl+uGxr1dcFLR7XZSKnh1N5CnC8cAuXmD0G9+E/JFW3hXCZANpj27f4ig/nRj2XJmR5t0N8g C/nkdVRHvO428Yn2iaDw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pcMsQ-00CpXL-2Y; Wed, 15 Mar 2023 08:52:54 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pcMsO-00CpVJ-0B for linux-arm-kernel@lists.infradead.org; Wed, 15 Mar 2023 08:52:53 +0000 Received: by mail-wm1-x335.google.com with SMTP id c8-20020a05600c0ac800b003ed2f97a63eso580164wmr.3 for ; Wed, 15 Mar 2023 01:52:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678870364; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=ykAWNeQFRSXWiMQRkG7ruLQaPcfN8XGu9YKzk/Snc/Q=; b=BQIPymLAcma7QRPwFhP1SCgKxDz+SfyPo0BZ5YnIBypimiJNIdIVjljthH63jZWcwF d8bYbG4O2U0BiWygHqxKKpSTG1AYmf86deTWcC0dq83KHkdadblE1l20puzOOLIZMhTD OFnfwTsZGSZOjMoQi2nJUvAxFwuoosrXKmL3CiM2veEevgOm+IDgskl4mJRULPWqBqzJ Jf2pvI67KGhU01oXe3Yhoj1rKhhNrOx82c3dCXDJo8hSeWyf2nxZZ7vU76lu3htAjnsu JdR/V+eMIPYFzjj93XpLuZ7WZF9SjB0BFHSkncT7QkJVeqHD59zo6+sDhy2m3yR1NJSj lazQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678870364; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ykAWNeQFRSXWiMQRkG7ruLQaPcfN8XGu9YKzk/Snc/Q=; b=2O42deN5uHwUClxgGAZThGwXNR9ajviMAJN2xftKHv4nGmUm5HhEkPPhSbf/x5E5XW j4B+gw8pvS6egJVyQ1BCXFXM2DGS+pVzycsPmjHMWW9ZVvloNbPXIckPBYkLZaH8jAWc AVMrMUkxwQFqB5FBUrQaD4lWeatSpGEpsjybv4elLNagWKQN5DkRKWcoKO3aU1E4sw0p B2l4+0QBSjVqfuGaqLjUuSZ4Uat/Yiau0tjNh6mqDSslDYiyFKJMEFUjrXJuPmgGyH/+ 0uGYTWLiO0iXIurfx9TlX3bgmtGSQM+TPz9QWmC0mmakptiBwNE4KNAJ3kWZGWMNNq9h Oo2Q== X-Gm-Message-State: AO0yUKW9btNAxxiQwY06rW87TdooUZKTum2bbUYIBajXMrtrWGFszEGa fxkR+PNV8sEPCZKMJ7aIpxixhw== X-Google-Smtp-Source: AK7set/RAG8oBPytHBTgXi0rwcT4pPmQk9JiqoCjmsORZ3sqvP/Bx9lKF6pT5D+7Pw0eA35X0TKhCQ== X-Received: by 2002:a05:600c:cc6:b0:3ed:2949:9847 with SMTP id fk6-20020a05600c0cc600b003ed29499847mr7151983wmb.10.1678870363925; Wed, 15 Mar 2023 01:52:43 -0700 (PDT) Received: from elver.google.com ([2a00:79e0:9c:201:54ce:e7e7:a29b:ab5f]) by smtp.gmail.com with ESMTPSA id y25-20020a1c4b19000000b003ed2a3eab71sm1113920wma.31.2023.03.15.01.52.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Mar 2023 01:52:40 -0700 (PDT) Date: Wed, 15 Mar 2023 09:52:33 +0100 From: Marco Elver To: Zhenhua Huang Cc: Pavan Kondeti , catalin.marinas@arm.com, will@kernel.org, glider@google.com, dvyukov@google.com, akpm@linux-foundation.org, robin.murphy@arm.com, mark.rutland@arm.com, jianyong.wu@arm.com, james.morse@arm.com, wangkefeng.wang@huawei.com, linux-arm-kernel@lists.infradead.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, quic_guptap@quicinc.com, quic_tingweiz@quicinc.com, quic_charante@quicinc.com Subject: Re: [PATCH v8] mm,kfence: decouple kfence from page granularity mapping judgement Message-ID: References: <1678777502-6933-1-git-send-email-quic_zhenhuah@quicinc.com> <20230314083645.GA556474@hu-pkondeti-hyd.qualcomm.com> <20230314111422.GB556474@hu-pkondeti-hyd.qualcomm.com> <3253f502-aa2e-f8c9-b5bd-8eb20e5f6c5e@quicinc.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <3253f502-aa2e-f8c9-b5bd-8eb20e5f6c5e@quicinc.com> User-Agent: Mutt/2.2.9 (2022-11-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230315_015252_091657_B1F08AD6 X-CRM114-Status: GOOD ( 21.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 Wed, Mar 15, 2023 at 02:51PM +0800, Zhenhua Huang wrote: [...] > > Is it possible to free this early allocated memory later in > > mm_init()->kfence_alloc_pool()? if that is not possible, can we think of > > adding early param for kfence? > > If we freed that buffer, there may be no chance to get that page granularity > mapped buffer again.. as all these allocation/free are through normal buddy > allocator. > > At this stage, seems only additional early param can work.. Marco previously > wanted to reuse sample_interval but seems not doable now. > > Hi Marco, > > Sorry, Can we thought of the solution again? like > ARM64: > 1. intercepts early boot arg and gives early alloc memory to KFENCE > 2. KFENCE to disable dynamic switch > 3. disable page gran and save memory overhead > The purpose is in the case of w/o boot arg, it's just same as now.. arch > specific kfence buffer will not allocate. And w/ boot arg, we can get > expected saving. You can get kfence.sample_interval with early_param(). mm/kfence/core.c should be left as is with a module param, so it can be set at runtime in /sys/modules/kfence/parameters/. However you can add this to the #ifdef CONFIG_KFENCE in arm64 code you're adding: static bool kfence_early_init __initdata = !!CONFIG_KFENCE_SAMPLE_INTERVAL; static int __init parse_kfence_early_init(char *p) { int val; if (get_option(&p, &val)) kfence_early_init = !!val; return 0; } early_param("kfence.sample_interval", parse_kfence_early_init); Nothing is preventing us from parsing kfence.sample_interval twice during boot. At this stage you don't need the actual sample_interval, only if kfence.sample_interval was provided on the cmdline and is not 0. That will avoid adding another new param. Thanks, -- Marco _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel