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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01918C77B6F for ; Fri, 14 Apr 2023 10:19:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8354A6B007B; Fri, 14 Apr 2023 06:19:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E5736B007D; Fri, 14 Apr 2023 06:19:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6ACCA900002; Fri, 14 Apr 2023 06:19:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5DAC86B007B for ; Fri, 14 Apr 2023 06:19:08 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 1B32A1601DF for ; Fri, 14 Apr 2023 10:19:08 +0000 (UTC) X-FDA: 80679598776.18.2D45BFB Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by imf09.hostedemail.com (Postfix) with ESMTP id 28F5E140010 for ; Fri, 14 Apr 2023 10:19:05 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=HjXeb8lq; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf09.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681467546; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oxm+Jbd0/Tkjw/vGhSVmsyY0h1pCAWJpxgNwHUNcSZ8=; b=4ElLQRL9eDQwAVmw0ojpsqq/G87vWz1RxNdOSLGrDrDzxRHRDk3RtcLki752/z5n7dRIYM ZRjG8r2PkycRa6NUHueOCmrH2AMEFP6ygBG2js+/Ace0qjZQQbGxO5K8+DWea+VU3JL+9D 97hvXN9jwmU/rxbFU+22dTqieO3l6vI= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=suse.com header.s=susede1 header.b=HjXeb8lq; dmarc=pass (policy=quarantine) header.from=suse.com; spf=pass (imf09.hostedemail.com: domain of mhocko@suse.com designates 195.135.220.29 as permitted sender) smtp.mailfrom=mhocko@suse.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681467546; a=rsa-sha256; cv=none; b=3gktlOIoENJC6WRkrT5xCkOk/3wmmkN0ic1X7WqTU0dtv+/49ttgdM33Cc9YQi6qyDLm/y JnLV85s4hJn+NE811oEGZl4UwZaXkF7rfQ+/2p+e37gNgVu3tKI8osy0IJwSDsPLUQPCN+ f0qujEmamJAcmwZL9T6wIK0bjJhu9Js= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B96791FD95; Fri, 14 Apr 2023 10:19:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1681467544; h=from:from:reply-to: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=oxm+Jbd0/Tkjw/vGhSVmsyY0h1pCAWJpxgNwHUNcSZ8=; b=HjXeb8lquZ6LFAsP8NfkDUKuHxmSIPuev7wDyM6h5va7AUsw22u/xHpgNzfjRQ0bZ6A2+B Ngo7JZu8RPnLoDf9V8UzAMRuCY5FQJ/7npoTINDjEgp2KZh1+v1M0WYKcDCRKZ7TB62Ze9 LOb0HC5cb20hDf6ADo2IJ6gUbRYrS+Y= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9A1D4139FC; Fri, 14 Apr 2023 10:19:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id pPttI5goOWRmJAAAMHmgww (envelope-from ); Fri, 14 Apr 2023 10:19:04 +0000 Date: Fri, 14 Apr 2023 12:19:03 +0200 From: Michal Hocko To: Mel Gorman Cc: Andrew Morton , Vlastimil Babka , Oscar Salvador , Yuanxi Liu , David Hildenbrand , Linux-MM , LKML Subject: Re: [PATCH] mm: page_alloc: Assume huge tail pages are valid when allocating contiguous pages Message-ID: References: <20230414082222.idgw745cgcduzy37@techsingularity.net> <20230414095204.7fz6trkj5i4mzthz@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230414095204.7fz6trkj5i4mzthz@techsingularity.net> X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 28F5E140010 X-Stat-Signature: ewke5fk4bot1sbi3sjigrtx4fc7ehouu X-HE-Tag: 1681467545-95213 X-HE-Meta: U2FsdGVkX1+YBAvcJNduLtHriAN/r/ZVKFvs/k88p4hg/gJSD0st0wio2qtnAenjaO8AXYgEDZ39v96vVtWR0gkhqWUFBWJ6k++7FG4gX3T6QSBaRfaPoQYUB12pS5vEdgu66GFv4DiFruwR6VZ97FoFwU+Gd0PynNm8gnOKYVT+tXJ87TReNd/kWzkebWCQkOJdg7y6RZ8SNzY+QKhfLClIDk2gHplEMFYvMDTcbZ2bRX0blasCzTJ0rVSzJmaFl0xbDDNZUqdtGQWX97hYFneYrtTxVRssAF5Rp3PuDmRoqEB4VLC8dRZU78ApM+RNhwC7qopUhT+yaNtSCfVooT44s83LTvH9hAFhK0cIQ+35MSzvAjwdNL1J5Bm6FzhaxZ489fURqEuNsXlYmXUPgbRvIAMg2TWLVd5npcp7y3OWz8fe1a2XwSXwDhtbFPimgDSJ/NozHQHaN7x+CxM1s1BfeeUFifojyGB37rkjjkNFId0eE4lrWW7hmoCIZteXMBJXv2oNm1EzNrwhE4szg4tVcy6pCTa64sQq5NM//PuxCqTo2TmyN/aQkfu43D0xsVlKFTnUAeRiZsCxAwqsszXbKL9BKDHzk7sb0zCcVBq5ZT2Z8s13RCumJZwu5R+3yM10DiHWX41bqlSY2xZxSIuZcsFgO/Gqcbc8vkG7zKf9gaM2r/EbvU2cwCXKXMIXp31TXxASLVU/rUxB6kWzcnIbk05NLl4f1eyBTH8S/H6Ev2SibsNotsOdBdWFaho9XqkUflMvPpOytTiR38XXiW3D2NuXpMEAnYvHOoDwP4jJVfYN3M6CE8E5n+Hx1j2J0gaAICjw8N2MbHt/rsE8qSl9eHTRHS6RDNykjEykV3KPEGNz9QrexrXYO16yAKM229XhcryM8WA7075voLb8Q67d6Dx1N+uJOMUM1O1TvAte1Nz6wyMKXYybhcHMtq/3fIAuYu/9ReYftGS9uwr JvGXXswV 4k34vikZ8c3F8mPzyIJVR9I627dRJd5UAHE4CQxzMNKkD/OT62tyLKIfATUP98VMQ2ehm7BqwnKd+g5VahlBn9SO9irjaavJCxzrg4Vp7Red1xuOfMQjsUwU/GAxhG00x7nyYC3TpNlv6PU7yduTkeyoAABMLPdiMoaBBuv0sC7FD36A7RyUXySvJS8/iBDXAOQSPdLvclvfI33NnNOsREfmkew== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000034, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri 14-04-23 10:52:04, Mel Gorman wrote: > On Fri, Apr 14, 2023 at 10:55:04AM +0200, Michal Hocko wrote: > > On Fri 14-04-23 09:22:22, Mel Gorman wrote: > > [...] > > > + > > > + /* > > > + * Do not migrate huge pages that span the size of the region > > > + * being allocated contiguous. e.g. Do not migrate a 1G page > > > + * for a 1G allocation request. CMA is an exception as the > > > + * region may be reserved for hardware that requires physical > > > + * memory without a MMU or scatter/gather capability. > > > + * > > > + * Note that the compound check is race-prone versus > > > + * free/split/collapse but it should be safe and result in > > > + * a premature skip or a useless migration attempt. > > > + */ > > > + if (PageHuge(page) && compound_nr(page) >= nr_pages && > > > + !is_migrate_cma_page(page)) { > > > + return false; > > > > Is the CMA check working as expected? > > I didn't test it as I don't have a good simulator for CMA contraints which > is still a mobile phone concern for devices like cameras. > > > The function sounds quite generic > > and I agree that it would make sense if it was generic but it is used > > only for GB pages in fact and unless I am missing something it would > > allow to migrate CMA pages and potentially allocate over that region > > without any possibility to migrate GB page out so the CMA region would > > be essentially unusable for CMA users. > > It's used primarily for 1G pages but does have other users (debugging > mostly, low priority). As it's advertised as a general API, I decided to > treat it as such and that meant being nice to CMA if possible. If CMA pages > migrate but can still use the target location then it should be fine. If a > CMA can migrate to an usable location that breaks a device then that's a bug. > > > GB pages already have their CMA > > allocator path before we get to alloc_contig_pages. Or do I miss > > something? > > I don't think you missed anything. The CMA check is, at best, an effort > to have a potentially useful semantic but it's very doubtful anyone will > notice or care. I'm perfectly happy just to drop the CMA check because it's a > straight-forward fix and more suitable as a -stable backport. I'm also happy > to just go with a PageHuge check and ignore any possibility that a 2M page > could be migrated to satisfy a 1G allocation. 1G allocation requests after > significant uptime is a crapshoot at best and relying on them succeeding is > unwise. There is a non-zero possibility that the latency incurred migrating > 2M pages and still failing a 1G allocation could itself be classed as a > bug with users preferring fast-failure of 1G allocation attempts. Yes, the simpler the better. If we encounter a real usecase where couple of 2MB hugetlb pages stand in the way to GB pages then we can add the check so I would just go with reintroducing the PageHuge check alone. Thanks! -- Michal Hocko SUSE Labs