linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marco Elver <elver@google.com>
To: Zhenhua Huang <quic_zhenhuah@quicinc.com>
Cc: Pavan Kondeti <quic_pkondeti@quicinc.com>,
	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
Date: Wed, 15 Mar 2023 09:52:33 +0100	[thread overview]
Message-ID: <ZBGHUYJ2OY9Pz93U@elver.google.com> (raw)
In-Reply-To: <3253f502-aa2e-f8c9-b5bd-8eb20e5f6c5e@quicinc.com>

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

  reply	other threads:[~2023-03-15  8:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14  7:05 [PATCH v8] mm,kfence: decouple kfence from page granularity mapping judgement Zhenhua Huang
     [not found] ` <CANpmjNP2zDi9j+14-9Cqi5bMCuq7HcCi6om7SP_gfoVxs_AMbA@mail.gmail.com>
2023-03-14 10:31   ` Zhenhua Huang
     [not found] ` <20230314083645.GA556474@hu-pkondeti-hyd.qualcomm.com>
     [not found]   ` <b1273aad-c952-8c42-f869-22b6fd78c632@quicinc.com>
2023-03-14 11:14     ` Pavan Kondeti
2023-03-15  6:51       ` Zhenhua Huang
2023-03-15  8:52         ` Marco Elver [this message]
2023-03-15 11:19           ` Zhenhua Huang
2023-03-14 11:20     ` Zhenhua Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZBGHUYJ2OY9Pz93U@elver.google.com \
    --to=elver@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=catalin.marinas@arm.com \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=james.morse@arm.com \
    --cc=jianyong.wu@arm.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mm@kvack.org \
    --cc=mark.rutland@arm.com \
    --cc=quic_charante@quicinc.com \
    --cc=quic_guptap@quicinc.com \
    --cc=quic_pkondeti@quicinc.com \
    --cc=quic_tingweiz@quicinc.com \
    --cc=quic_zhenhuah@quicinc.com \
    --cc=robin.murphy@arm.com \
    --cc=wangkefeng.wang@huawei.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).