Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp347064pxf; Thu, 25 Mar 2021 05:41:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyRWJjYIM82fO00tfePqwnnLsX6nksKOnHdmOv4/x88P6SMjdmwuhLCT7i7CAUD6sAJALjQ X-Received: by 2002:aa7:dc0b:: with SMTP id b11mr9047358edu.124.1616676114114; Thu, 25 Mar 2021 05:41:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616676114; cv=none; d=google.com; s=arc-20160816; b=ed7L5J7o4ev4NYD/1hEFYG7tx0z0rCPmUx4BAM9PpQySwBvmpejyfYQVy5iKvA7wdk d/lIGa1t1geQH2R7nZ0BhBWvWt1j1QLLyRpfapDxRUu/dsEJ/DT2KW94parBzcG6/DAK ehNxTFzKxeAhCQsJHCouvs/9NVp+myaZTtIrHjHUaXZMLp6TFYNzbaOmcPUL9JMaf426 Zex8Hpe63sJFsRQcrRR7j0Mi0DIYTAyjgwi7QXpAxezXJcT4H3HB60ZVrkWIxBiREBhR R67AoCU6T3thnETgAtHzyo1ALfh7y4HYAhH5Gmagzi2eG49xxED2++ZETQJTpeu1F9Tv /ltA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=u1thINwJUDwJX23Ay10k6sh/wc4Y5TUlQBZ/eeo8LLM=; b=pKPyoXdF5qmlq4hJTdQNkSOhvEqT707p4o+BEhnQ8tAJRKx4yLNYviTdeE68hNP/kJ kJCeQUCeUSG2uP9wm/o2M+1zCi/hoaIwQi0LkyO05mXi0YfQFZOeEE3BGqwkrv+BngQx g3IEwbDp0qGPpGoxoSsyUuUrnpn/23tYTd+/mhl6f89qfxhOew8F6xu0m/OrEheIK9J1 +bOyhgSvtbSmYJZVeooqykoDu3bwRF3DGjeAwF+VST+U1z5lpp+l75fFMWLKXWXUA48H qeQkyQ1WqCX8Kys0pVJPHKimEf74vnLH5md23VrIhfYQNBEbyp20gzPulZJvYv2IB9Wb /qAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 d21si3968182edu.262.2021.03.25.05.41.30; Thu, 25 Mar 2021 05:41:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230281AbhCYMk4 (ORCPT + 99 others); Thu, 25 Mar 2021 08:40:56 -0400 Received: from outbound-smtp26.blacknight.com ([81.17.249.194]:36065 "EHLO outbound-smtp26.blacknight.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbhCYMkf (ORCPT ); Thu, 25 Mar 2021 08:40:35 -0400 Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp26.blacknight.com (Postfix) with ESMTPS id E07D6CAB4D for ; Thu, 25 Mar 2021 12:40:33 +0000 (GMT) Received: (qmail 19824 invoked from network); 25 Mar 2021 12:40:33 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.22.4]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 25 Mar 2021 12:40:33 -0000 Date: Thu, 25 Mar 2021 12:40:32 +0000 From: Mel Gorman To: Matthew Wilcox Cc: Andrew Morton , Chuck Lever , Jesper Dangaard Brouer , Christoph Hellwig , Alexander Duyck , Vlastimil Babka , Ilias Apalodimas , LKML , Linux-Net , Linux-MM , Linux-NFS Subject: Re: [PATCH 4/9] mm/page_alloc: optimize code layout for __alloc_pages_bulk Message-ID: <20210325124032.GR3697@techsingularity.net> References: <20210325114228.27719-1-mgorman@techsingularity.net> <20210325114228.27719-5-mgorman@techsingularity.net> <20210325121217.GV1719932@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20210325121217.GV1719932@casper.infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, Mar 25, 2021 at 12:12:17PM +0000, Matthew Wilcox wrote: > On Thu, Mar 25, 2021 at 11:42:23AM +0000, Mel Gorman wrote: > > > > - if (WARN_ON_ONCE(nr_pages <= 0)) > > + if (unlikely(nr_pages <= 0)) > > return 0; > > If we made nr_pages unsigned, we wouldn't need this check at all (ok, > we'd still need to figure out what to do with 0). But then, if a user > inadvertently passes in -ENOMEM, we'll try to allocate 4 billion pages. This is exactly why nr_pages is signed. An error in accounting by the caller potentially puts the system under severe memory pressure. This *should* only be a problem when a new caller of the API is being implemented. The warning goes away in a later patch for reasons explained in the changelog. > So maybe we should check it. Gah, API design is hard. Yep. -- Mel Gorman SUSE Labs