From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B95C371D05 for ; Thu, 6 Aug 2026 21:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786051206; cv=none; b=DseSzRpOsUtC4APdLDEmVMWuikUSM4MPv9SnnWn1PbKUlgpt4yHwzlaifc5Wca4DMqdYysC2h4951cwW1rxhw31nOGlcBXotuu13X4G/UJg1u8WcSLSWEEqN3lSfRQfxHwJF1KwyC4Fc3RX7V2hSYLkA+4Qwrpo9UtEUNQpVHQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786051206; c=relaxed/simple; bh=IHnxsLXWA3lzAgNPvtiZ7sPduuNrh+Lg7sCRViqOKcs=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=UdXcCZurxmJ7vvjxyO/i9a9enuEiobKyrmCj1zNJBdcv9aHl3/qiUNegWdY9C8NM8JAy6IWgXeUmgp9znjoDFKz8H0Zm2Xwwkkq4S1ckGjxMTygqjGC1BIxTRC9JqyZkmUHVatxIH7LOnoqZxjdLSOEw8CuUCudw4WSxJyAI3AM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=hrEk5wHD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="hrEk5wHD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31A131F000E9; Thu, 6 Aug 2026 21:20:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1786051203; bh=OH/jGTweKLDj5ljGoHRyVAtI3RPLntAr3emVuir6R8g=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=hrEk5wHDENIjlMUpYglMp8AUOxthBoNHko2cDBo4ILhPkeNeGv2vbzVajd5Cl9KfZ r8kXXsvuRJo4k6nCzL+cAmjIX2Fcqm3OH37dKA4zq5jQ7cn9cTcWxFOrJfszmY8k1h cDxyhIGIMzo11FQs4+okpNRoF+TcEYUhcJFsCUWI= Date: Thu, 6 Aug 2026 14:20:02 -0700 From: Andrew Morton To: Johannes Weiner Cc: Jianlin Shi , linux-mm@kvack.org, vbabka@kernel.org, surenb@google.com, mhocko@suse.com, jackmanb@google.com, ziy@nvidia.com, linux-kernel@vger.kernel.org, Joel Granados Subject: Re: [PATCH v5] mm/page_alloc: only update lowmem_reserve_ratio on sysctl write Message-Id: <20260806142002.ac4a349730f3ce15154a71a5@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 6 Aug 2026 09:50:16 -0400 Johannes Weiner wrote: > > - proc_dointvec_minmax(table, write, buffer, length, ppos); > > + if (!write) > > + return proc_dointvec_minmax(table, write, buffer, length, ppos); > > > > - for (i = 0; i < MAX_NR_ZONES; i++) { > > - if (sysctl_lowmem_reserve_ratio[i] < 1) > > - sysctl_lowmem_reserve_ratio[i] = 0; > > - } > > This could use a comment. How about: > > /* > * proc_dointvec_max() works incrementally. Use a buffer > * and only set the values if all of them parse cleanly. > */ > I added a fixlet: --- a/mm/page_alloc.c~mm-page_alloc-only-update-lowmem_reserve_ratio-on-sysctl-write-fix +++ a/mm/page_alloc.c @@ -6932,6 +6932,10 @@ static int lowmem_reserve_ratio_sysctl_h if (!write) return proc_dointvec_minmax(table, write, buffer, length, ppos); + /* + * proc_dointvec_max() works incrementally. Use a buffer and only set + * the values if all of them parse cleanly. + */ memcpy(ratio, sysctl_lowmem_reserve_ratio, sizeof(ratio)); tmp.data = ratio; _ Sashiko got all upset about concurrency issues: https://sashiko.dev/#/patchset/tencent_A860C873956A52E26AD8D309A308A241BA08@qq.com But I think I'm hearing from Joel is that the longer-term plan is to fix all this up within proc_dointvec_minmax()?