From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 638AAC433E0 for ; Wed, 24 Jun 2020 14:08:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0280720781 for ; Wed, 24 Jun 2020 14:08:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M9vXgXFE" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0280720781 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3C82B6B0003; Wed, 24 Jun 2020 10:08:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3777D6B0005; Wed, 24 Jun 2020 10:08:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 267746B0006; Wed, 24 Jun 2020 10:08:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0200.hostedemail.com [216.40.44.200]) by kanga.kvack.org (Postfix) with ESMTP id 10E766B0003 for ; Wed, 24 Jun 2020 10:08:54 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B6E841804FAE1 for ; Wed, 24 Jun 2020 14:08:53 +0000 (UTC) X-FDA: 76964286546.19.page31_1a0339b26e44 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 5DC7A1AB9EC for ; Wed, 24 Jun 2020 14:07:37 +0000 (UTC) X-HE-Tag: page31_1a0339b26e44 X-Filterd-Recvd-Size: 3751 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by imf19.hostedemail.com (Postfix) with ESMTP for ; Wed, 24 Jun 2020 14:07:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593007655; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fb1hGmmynErPFt50plAm995F3DUgaKJEUj59Ai0NXUQ=; b=M9vXgXFE4oUh2xSO1fE9SUGxyas0iA+tufe52gI2eVAl25lXpFXO9I8+hcuZiBD9NSv39T UXxN6UTSTepsNpM/HMSuxl8ofvmCUqjsEkPW2TwV8sPSaei8rk3WRpgyso2bq91yBnOqA3 u4vtYflmS+flswq9UtZQUOw+kLZJdK4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-42--oXbM6TfPw2uTZkuhV0dJA-1; Wed, 24 Jun 2020 10:07:33 -0400 X-MC-Unique: -oXbM6TfPw2uTZkuhV0dJA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69ADC107ACCD; Wed, 24 Jun 2020 14:07:32 +0000 (UTC) Received: from optiplex-lnx (unknown [10.3.128.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C16A619B1; Wed, 24 Jun 2020 14:07:30 +0000 (UTC) Date: Wed, 24 Jun 2020 10:07:27 -0400 From: Rafael Aquini To: Matthew Wilcox Cc: Joel Savitz , linux-kernel@vger.kernel.org, Vlastimil Babka , John Hubbard , Andrew Morton , linux-mm@kvack.org Subject: Re: [PATCH] mm/page_alloc: fix documentation error and remove magic numbers Message-ID: <20200624140727.GA1987277@optiplex-lnx> References: <20200624032712.23263-1-jsavitz@redhat.com> <20200624111255.GL21350@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200624111255.GL21350@casper.infradead.org> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Rspamd-Queue-Id: 5DC7A1AB9EC X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Jun 24, 2020 at 12:12:55PM +0100, Matthew Wilcox wrote: > 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; > > + I think these constants would look better if declared as an enum. > > 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! >