Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp614250ybt; Wed, 24 Jun 2020 07:10:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjxV7R8L9KyYyt0v0MZT24OSqjyB4kx6YzWukJbQ7AY9LcxUqSvoiiz0uH2GPBh21aK9qn X-Received: by 2002:aa7:d492:: with SMTP id b18mr27404075edr.339.1593007833657; Wed, 24 Jun 2020 07:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593007833; cv=none; d=google.com; s=arc-20160816; b=dLlCNp967dgAguNrj4zS9C9yTp82sudtOOQpE5xnO8OhSF1seI54mcIKCz9ue7h0/N m/XYuQMfdByT3En7jHOkrdd37Y4fZ1Rbbe7Bsq7StwCYyNr6zdS0ighIQEF17uXVTjl9 c/5tuHjj3XqOj/fOJbW1H/UVg7XKO6kjtK0uCQI7tZ5onkEF96A+PLhpffIc+8Yv1DEr JFa87txLRQdU6RX3g9Tk+hPQOpLNNezocLyx4cpL+AlprgVC0BQGznXQDFYExUdNx1s8 dh9O0Wxg1+KlEFzXpI/13SqhvI2tBGvqbcG++4hXw2wvH3ox4TFAnLiB0sO5DJalrht7 dleQ== 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=fb1hGmmynErPFt50plAm995F3DUgaKJEUj59Ai0NXUQ=; b=Wpe2CzGATMqYgivw0jaZxFNhDDWz7Fzik+UE1XDHxE/ZYXY+uKrn/Go4SSDJ5kfwnt q5NG8OMhr2oWTqEugCY/xEMf/a8cwqbfC0u96WdX3VTq2UYc0kFzuJ4cZY5N7IJMa7ff HdLNOXRbrfvTgD7j40sXyi4aYPHY4pz0Ngef6leLvQFuh32blPENe3CNDcFiLEVd+SWp KUDwtj1v3bbbQY68WpH58uO+HnjKBl2qigxhIcz8wpaCLXUd0nE1Rbtt7+m7ewhVUoMr x/3xQZVueqiaq5FvGbiZcO7spUudIrHHHx4XTUlh2VuxkHh99N920lnVf2vXqvkdcHNk 5gzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QICUtErs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id df15si602850edb.366.2020.06.24.07.10.10; Wed, 24 Jun 2020 07:10:33 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QICUtErs; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391062AbgFXOHi (ORCPT + 99 others); Wed, 24 Jun 2020 10:07:38 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:37633 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388395AbgFXOHi (ORCPT ); Wed, 24 Jun 2020 10:07:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593007657; 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=QICUtErsSX9efb0eLEoA5Xfb1QKABt+ZbTZ2R6RcHFM9Px9L4Uf1Jk9mBjxKmLxDcuH4o6 ibqrO3uIQTkjFkAOtL/l74GOJ6Ta8eWugMi6Eq+fG6ttr3TZhuNNen7aHh6mffGffpOrr4 6HwZ00AZyKvk7tcS8OmNqVkYhI9VcS4= 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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! >