Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp485247ybt; Wed, 24 Jun 2020 04:14:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJn/xwu6YDVcyRF5Q+potfofR2PTK9xQn/fTRoSNJT0bwZk+bcFzBOXfB0lFoCoTaYayVP X-Received: by 2002:a50:e801:: with SMTP id e1mr6172645edn.251.1592997272666; Wed, 24 Jun 2020 04:14:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592997272; cv=none; d=google.com; s=arc-20160816; b=t/7DDx++1TL21WxsBgd9wsFHHteWfiw7+OYyE4eRMHnBgsp3rWcztcxHEcf+eO7Nq9 YgZQVfVtKsOgr4Mw52ZdhBbqEY6vU5D2TguzU11u0rvBOCn94axWHyt8SI1nl6rbZlk4 sHzMTJJvKCQCyFcf+/KrFyBxpcCANl7luvXhTyjeInvLKl1N/QAVRmdpZHPAcLCs/KSx xRiHsPaNtHvDCzEGhSD8rTReHRl0JWjiT25UJf2Bd0cB5tW3IoNeujoTpf7fhLlCnu+E WxrWxBDvJ263ckv7VXynUKqp95Gmhd+elOh7Il2EciE0ibe5hvYDNTYaoYebB2jE9qIv Pxxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=o+wrDuDEOBRD8xp7VlW4WFiVlPd+yRCvyexu2cGK4ug=; b=q5jVPBZUt1N1wgpejLWOvY5dhP48+7woEvFXaYySu7wIy0MV3yLcyey7gW5yUvcMLa 0LUyIUUhIEyNXP0H3/ToVIZJ5BjMqAIAtWN03Apgi9e0sgz8WvF9r7/BDEBgFthHKL/O +mxwfOVOZEYkmBjEtb5VH58mgUen5vQ5wxJ32ZZKDEi7aaaIlGWUUhwSE6JkDknNjUL4 wY/pfI6TSFk81JxZb0Xr6MCsXLHl78qgnfS/FPMMS2TNR/Cjgb0/PATe96/WJx8I8ich j1g0k1cT4TyfjWlGayAsRA9ZtGyjjnYLVU4I03MqMzPCKCF7sAi1+TstB0+3HT2a758F nDlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=uu6sySxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u11si15034539edd.259.2020.06.24.04.14.08; Wed, 24 Jun 2020 04:14:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=uu6sySxg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389088AbgFXLNO (ORCPT + 99 others); Wed, 24 Jun 2020 07:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728656AbgFXLNN (ORCPT ); Wed, 24 Jun 2020 07:13:13 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3501DC061573 for ; Wed, 24 Jun 2020 04:13:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=o+wrDuDEOBRD8xp7VlW4WFiVlPd+yRCvyexu2cGK4ug=; b=uu6sySxgKDDgJoBHjuKpYnDFAk wN1sRUtDSglgsjM9dH3HJQY2ht+gocnxs5fhwqVMQGAoSxpqRg7RLJfv2nRzPCS5Ff1FpO2FUuSd/ qov/JJCwkeBAD7uR7wzz1IbVsZmg8OxSIxpckpafKijTLjzwEUcWEBWvngmfL07YqIld10vXxeKDk 6nD46lnLCecuY/LMaH71FiMAMXwyzTcH9hMLhGEieuw/q5Zh6InPKVuJRW42p8ia/ICsyIvnm91PN pVWKARuUQTm7I6AxHamRvcbmrh+/UmrgLMcViXKSXocoAHlLbNqwhJ2niGopF1lz6ye4+hQSt3Urw bRg5UoDQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jo3Kp-0008Jh-8M; Wed, 24 Jun 2020 11:12:55 +0000 Date: Wed, 24 Jun 2020 12:12:55 +0100 From: Matthew Wilcox To: Joel Savitz Cc: linux-kernel@vger.kernel.org, Vlastimil Babka , John Hubbard , Andrew Morton , Rafael Aquini , linux-mm@kvack.org Subject: Re: [PATCH] mm/page_alloc: fix documentation error and remove magic numbers Message-ID: <20200624111255.GL21350@casper.infradead.org> References: <20200624032712.23263-1-jsavitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624032712.23263-1-jsavitz@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 23, 2020 at 11:27:12PM -0400, Joel Savitz wrote: > In addition, this patch replaces the magic number bounds with symbolic > constants to clarify the logic. Why do people think this kind of thing makes the code easier to read? It actually makes it harder. Unless the constants are used in more than one place, just leave the numbers where they are. > @@ -7852,6 +7852,9 @@ void setup_per_zone_wmarks(void) > * 8192MB: 11584k > * 16384MB: 16384k > */ > +static const int MIN_FREE_KBYTES_LOWER_BOUND = 1 << 7; > +static const int MIN_FREE_KBYTES_UPPER_BOUND = 1 << 18; > + > int __meminit init_per_zone_wmark_min(void) > { > unsigned long lowmem_kbytes; > @@ -7862,10 +7865,10 @@ int __meminit init_per_zone_wmark_min(void) > > if (new_min_free_kbytes > user_min_free_kbytes) { > min_free_kbytes = new_min_free_kbytes; > - if (min_free_kbytes < 128) > - min_free_kbytes = 128; > - if (min_free_kbytes > 262144) > - min_free_kbytes = 262144; > + if (min_free_kbytes < MIN_FREE_KBYTES_LOWER_BOUND) > + min_free_kbytes = MIN_FREE_KBYTES_LOWER_BOUND; > + if (min_free_kbytes > MIN_FREE_KBYTES_UPPER_BOUND) > + min_free_kbytes = MIN_FREE_KBYTES_UPPER_BOUND; The only thing I'd consider changing there is replacing 262144 with 256 * 1024. 1 << 18 is not clearer!