lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87y1epr8gx.fsf@devkernel.io>
Date:   Wed, 22 Nov 2023 09:41:16 -0800
From:   Stefan Roesch <shr@...kernel.io>
To:     David Hildenbrand <david@...hat.com>
Cc:     kernel-team@...com, akpm@...ux-foundation.org, hannes@...xchg.org,
        riel@...riel.com, linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [PATCH v2 2/4] mm/ksm: add sysfs knobs for advisor


David Hildenbrand <david@...hat.com> writes:

> On 28.10.23 02:09, Stefan Roesch wrote:
>> This adds four new knobs for the KSM advisor to influence its behaviour.
>> The knobs are:
>> - advisor_mode:
>>      0: no advisor (default)
>>      1: scan time advisor
>> - advisor_min_cpu: 15 (default, cpu usage percent)
>> - advisor_max_cpu: 70 (default, cpu usage percent)
>> - advisor_min_pages: 500 (default)
>> - advisor_max_pages: 30000 (default)
>> - advisor_target_scan_time: 200 (default in seconds)
>> The new values will take effect on the next scan round.
>> Signed-off-by: Stefan Roesch <shr@...kernel.io>
>> ---
>>   mm/ksm.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 154 insertions(+)
>> diff --git a/mm/ksm.c b/mm/ksm.c
>> index e18fecfb359d..042ecaeb0beb 100644
>> --- a/mm/ksm.c
>> +++ b/mm/ksm.c
>> @@ -351,6 +351,14 @@ static void init_advisor(void)
>>   	advisor_ctx.cpu_time = 0;
>>   }
>
>
> [...]
>
>>    * Use previous scan time if available, otherwise use current scan time as an
>>    * approximation for the previous scan time.
>> @@ -3719,6 +3727,146 @@ static ssize_t smart_scan_store(struct kobject *kobj,
>>   }
>>   KSM_ATTR(smart_scan);
>>   +static ssize_t advisor_mode_show(struct kobject *kobj,
>> +				 struct kobj_attribute *attr, char *buf)
>> +{
>> +	return sysfs_emit(buf, "%u\n", ksm_advisor);
>> +}
>> +
>> +static ssize_t advisor_mode_store(struct kobject *kobj,
>> +				  struct kobj_attribute *attr, const char *buf,
>> +				  size_t count)
>> +{
>> +	unsigned int mode;
>> +	int err;
>> +
>> +	err = kstrtouint(buf, 10, &mode);
>> +	if (err)
>> +		return -EINVAL;
>> +	if (mode > KSM_ADVISOR_LAST)
>> +		return -EINVAL;
>> +
>> +	/* Set advisor default values */
>> +	ksm_advisor = mode;
>> +	init_advisor();
>> +	set_advisor_defaults();
>> +
>> +	return count;
>
> Can we instead use human-readable strings?
>
> "none" and "scan-time" should be clearer.
>

I'll change the interface to use strings instead of numbers.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ