Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4454719ybi; Tue, 11 Jun 2019 06:59:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJvX1Kza+efurYLvRnRgvK8/LUpSbfizOVlAiff61PmUs7L2sixxK9AW/Ffy+aeMhbxaHF X-Received: by 2002:a17:90a:e38f:: with SMTP id b15mr27321320pjz.85.1560261596847; Tue, 11 Jun 2019 06:59:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560261596; cv=none; d=google.com; s=arc-20160816; b=yDh3snyGs4KIGG3fG1P4uwEPK66Rng0BBXGf23TBNdWea+qrX00VpdoGWMVR+BKEKR K6ElTTjUluMvE7WWUxyM5vNytTDmUzF8z3Vp+aA6DyNqrL0KOIRGv7l/27KP7NUichTp 9MPP0wNNGHjazi2XRFVFvm6Q+qGnkJyZCWapxzIiNB06ayiR3hJWgzocnb+ruuZ62K1c GAGlKA0e0I41b4uMZ54XJS1o35vHcfYnyA2hGqnW4SnCKxNO1mqwvKztbzVS02SA8Gga 4VeWbaH6rqgBHprzjdPdeaDWyJFRQQLXtep9k+v8A4msyhX5bruJZ+BCLZrF0irOUATW eUWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=zG7D9tA9mltNdg5ILkPGMptmgP7ku2Sk3DeC7scybP4=; b=SYcLLW5ClU/4CK1lDJoSbcuE0jb9rLukfVb05p0EKmzM+35vVOjJ9xLgGtJ02g0fsc KKv7YeWO+tPlWOIadxSf08zRcERe/NuaVIZjB5YdILdBff/KQKUMR9f6L9VSuvDGHEt2 haclhGzRf042PFkgVA77iNFViTj/kP+nLlsO6VDWvlvnKj88oseZc/6sqK0t3iseAVgf UqG6S3hPczZujLcLZLMYfMQoWVmTbbrODgk0Bs32hdZbwPM1I5SfJ+8cTqIvzWkBkVwk O1DiBNno0jUTV6jtvexA/xKxSnXtadBDVBFXmuDSrO4QRNOZDDfQdVkiSzI6GnxTmVoA zFQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si12909260plu.126.2019.06.11.06.59.42; Tue, 11 Jun 2019 06:59:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728981AbfFKNIW (ORCPT + 99 others); Tue, 11 Jun 2019 09:08:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:56766 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726713AbfFKNIW (ORCPT ); Tue, 11 Jun 2019 09:08:22 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id B5CA9ADD4; Tue, 11 Jun 2019 13:08:20 +0000 (UTC) Date: Tue, 11 Jun 2019 15:08:20 +0200 From: Michal Hocko To: "Chengang (L)" Cc: "akpm@linux-foundation.org" , "vbabka@suse.cz" , "osalvador@suse.de" , "pavel.tatashin@microsoft.com" , "mgorman@techsingularity.net" , "rppt@linux.ibm.com" , "richard.weiyang@gmail.com" , "alexander.h.duyck@linux.intel.com" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] mm: align up min_free_kbytes to multipy of 4 Message-ID: <20190611130820.GI2388@dhcp22.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 11-06-19 12:16:35, Chengang (L) wrote: > Hi Michal > > > >On Sun 09-06-19 17:10:28, ChenGang wrote: > >> Usually the value of min_free_kbytes is multiply of 4, and in this > >> case ,the right shift is ok. > >> But if it's not, the right-shifting operation will lose the low 2 > >> bits, and this cause kernel don't reserve enough memory. > >> So it's necessary to align the value of min_free_kbytes to multiply of 4. > >> For example, if min_free_kbytes is 64, then should keep 16 pages, but > >> if min_free_kbytes is 65 or 66, then should keep 17 pages. > > >Could you describe the actual problem? Do we ever generate min_free_kbytes that would lead to unexpected reserves or is this trying to compensate for those values being configured from the userspace? If later why do we care at all? > > >Have you seen this to be an actual problem or is this mostly motivated by the code reading? > > I haven't seen an actual problem, and it's motivated by code > reading. Users can configure this value through interface > /proc/sys/vm/min_free_kbytes, so I think a bit precious is better. The interface is intended for admins and they should better know what they are doing, right? Using an ad-hoc valus is not something that is a common usecase. That being said, your change makes the code slightly harder to read and the benefit is not entirely clear from the changelog (which btw. sounds like there is a real problem which is not described in the user visible terms). So if you really believe this change is worth it, then make sure you justify it by exaplain what is a negative consequence of a dubious value set by an admin. > >> Signed-off-by: ChenGang > >> --- > >> mm/page_alloc.c | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d66bc8a..1baeeba > >> 100644 > >> --- a/mm/page_alloc.c > >> +++ b/mm/page_alloc.c > >> @@ -7611,7 +7611,8 @@ static void setup_per_zone_lowmem_reserve(void) > >> > >> static void __setup_per_zone_wmarks(void) { > >> - unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT - 10); > >> + unsigned long pages_min = > >> + (PAGE_ALIGN(min_free_kbytes * 1024) / 1024) >> (PAGE_SHIFT - 10); > >> unsigned long lowmem_pages = 0; > >> struct zone *zone; > >> unsigned long flags; > >> -- > >> 1.8.5.6 > >> > > >-- > >Michal Hocko > >SUSE Labs -- Michal Hocko SUSE Labs