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=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 32DA8C433DB for ; Thu, 25 Mar 2021 12:40:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B6BD961A1D for ; Thu, 25 Mar 2021 12:40:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6BD961A1D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=techsingularity.net Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 4AAB86B006C; Thu, 25 Mar 2021 08:40:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45B696B0070; Thu, 25 Mar 2021 08:40:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FE586B0071; Thu, 25 Mar 2021 08:40:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id 0F9116B006C for ; Thu, 25 Mar 2021 08:40:36 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C12561AECF for ; Thu, 25 Mar 2021 12:40:35 +0000 (UTC) X-FDA: 77958355230.24.BDF5E32 Received: from outbound-smtp21.blacknight.com (outbound-smtp21.blacknight.com [81.17.249.41]) by imf25.hostedemail.com (Postfix) with ESMTP id 0C1AA600010E for ; Thu, 25 Mar 2021 12:40:33 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp21.blacknight.com (Postfix) with ESMTPS id E33AFCCA91 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) X-Stat-Signature: aj1urq1pxm7tt7bxqpq14qppps7xdd5n X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 0C1AA600010E Received-SPF: none (techsingularity.net>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=outbound-smtp21.blacknight.com; client-ip=81.17.249.41 X-HE-DKIM-Result: none/none X-HE-Tag: 1616676033-750868 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 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