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 53007C77B70 for ; Fri, 14 Apr 2023 10:31:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C27AF900002; Fri, 14 Apr 2023 06:31:53 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BB0C86B0075; Fri, 14 Apr 2023 06:31:53 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2A91900002; Fri, 14 Apr 2023 06:31:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8F8FC6B0072 for ; Fri, 14 Apr 2023 06:31:53 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 57757AB1E1 for ; Fri, 14 Apr 2023 10:31:53 +0000 (UTC) X-FDA: 80679630906.11.35135CC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 316C74000F for ; Fri, 14 Apr 2023 10:31:50 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AjGrTNqN; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681468311; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Z4OY31S9mUHw6BlIMwhzxwBlTgpR3iZTfz/4sQFURp8=; b=hDkmAMCbrAzfPOhhf6BQWMZjovDAdOg/B1/Pd13pOl9lveVA4FbHEH25K11lNjb81bOODA XN4oR0zKT+THOO44AfDMN52mMFVqFpMbSu4Owp6oioT/XwOpMxEwNDdhaXIUb1/2phn2nr chSFA2SAyVnVMgouyS2CmkYCu9PzGIw= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AjGrTNqN; spf=pass (imf01.hostedemail.com: domain of david@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681468311; a=rsa-sha256; cv=none; b=wyVUNt8zywuo5KmnueywBsi6xqrZYfymBYdLRa46aEzt4W6i1e5P3/VlOKdZSNTB0R3f3l RkMdNja8iRfyyWQa3uIUm5Ki2ovEzLb57ivzcP/lWboCf0X7bX5mxOrpcRh4ZKwaT7DtXy nfqtlg70V4we/w7CifCzYnH4T0eUQis= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681468307; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z4OY31S9mUHw6BlIMwhzxwBlTgpR3iZTfz/4sQFURp8=; b=AjGrTNqN/QXfiCAO8noubXFkuZIcsH2irAWgwPgWKVZvXjezcGxIkY4tzjd+PJW8xkVSEh HST6QceSkypbiPH8y5yJoSQVAoYnCUWaqN9QX4WOlu366azjrs6nSFV35BWQSa2UWB5KDh SbB601jgBuPE2K0jDExVhhZV9aLLxxg= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-633-WOq1Wt7HMse6MBMIVyMK0g-1; Fri, 14 Apr 2023 06:31:46 -0400 X-MC-Unique: WOq1Wt7HMse6MBMIVyMK0g-1 Received: by mail-wm1-f72.google.com with SMTP id m7-20020a05600c3b0700b003ee112e6df1so5984347wms.2 for ; Fri, 14 Apr 2023 03:31:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681468305; x=1684060305; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z4OY31S9mUHw6BlIMwhzxwBlTgpR3iZTfz/4sQFURp8=; b=WYPIqXcZRBM24PHZDR5PS0/h+mPhv16rNc8TgOoH6tMJP/R0rf3+vAYjZHXCbu8hsy yPd2Dbnn1RwuRgO6Xol4sS6jviSs6voVUagKRddUxHtcg4SpuBNqNwkRl3H9vi3N8/z8 s0ecpYKhCeCzvqW0RU1qPZjMf46G14cA00n7lK6HxDL2i58R2Sr6U+B7YV6vWkZmopUT Aq4opu0M5HJPLQqHjCoRGaGyoTfkDbnq+YMjKM62e/PBbGZ/oJNSjMDsL7KlOk4S+gAr qqcdqRADIZV7DkJG5NFdh683SnrcWbmdgTRxiQidre8CpLfsWdTP827ob33oa3vLKBiN 66cA== X-Gm-Message-State: AAQBX9f6SyWfDW7R6WKKEU2crgPnPUBnKP3cw44gKGps/vVs83cZa6LZ 5d6mtdMKEiV/R0DLrlpYJJkfsCVGmxA/Cs2M+sw5QTfLgCH79D3YgKzQpEaGm/Cq3NeIVD9Mbq+ zClP8RVUEQ2c= X-Received: by 2002:a05:6000:107:b0:2f4:170:3807 with SMTP id o7-20020a056000010700b002f401703807mr3923337wrx.44.1681468305138; Fri, 14 Apr 2023 03:31:45 -0700 (PDT) X-Google-Smtp-Source: AKy350YJev2/y8Y93fyj23BgYm40VnAb0CKaZh0JPuItMitr0VyPEpZgKjy6MkOkxfO8rUIFpCcLkQ== X-Received: by 2002:a05:6000:107:b0:2f4:170:3807 with SMTP id o7-20020a056000010700b002f401703807mr3923315wrx.44.1681468304747; Fri, 14 Apr 2023 03:31:44 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:5700:cb5b:f73a:c650:1d9? (p200300cbc7025700cb5bf73ac65001d9.dip0.t-ipconnect.de. [2003:cb:c702:5700:cb5b:f73a:c650:1d9]) by smtp.gmail.com with ESMTPSA id p11-20020a5d458b000000b002efb31d3c24sm3251251wrq.32.2023.04.14.03.31.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Apr 2023 03:31:44 -0700 (PDT) Message-ID: <832d4026-c88f-876b-5f95-4d573bb9d1dd@redhat.com> Date: Fri, 14 Apr 2023 12:31:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH] mm: page_alloc: Assume huge tail pages are valid when allocating contiguous pages To: Michal Hocko , Mel Gorman Cc: Andrew Morton , Vlastimil Babka , Oscar Salvador , Yuanxi Liu , Linux-MM , LKML References: <20230414082222.idgw745cgcduzy37@techsingularity.net> <20230414095204.7fz6trkj5i4mzthz@techsingularity.net> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 316C74000F X-Stat-Signature: ahkq195yiccaf9nkc3mn396porjad8ys X-Rspam-User: X-HE-Tag: 1681468310-143136 X-HE-Meta: U2FsdGVkX18Xl9Lim2pORpKV9344XiOStkhMLTt3bFlxPAeAmYoASVTj0ha8d4rqFjzpdAA6WAmeF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1Zab+1BmToO1RPqZGjQM07ttmorwCHFs2ytTY/lr95mrTPRMM23rTLy/+NW0+2Unl8UYZrw1YoIXEnWYwEbBsUqp7w9GJ6kvDpomgzAZBko5Kf2T9qNMulfp1ApBa/xcMO7kF9EK1L1tJ9o/f85dqfrwyh7KkSPutKnWpYgG9kjO//H6kWz5j8hoDInNuzFvkHLszgBq4cT0EdeQ7uU0/q7rKrqCZJcVkQY9kRMxZEBaBshoGMUJbKst+sKZPwh+V+aRT0p6A9Rqd+cozPl6jjtsef X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 14.04.23 12:19, Michal Hocko wrote: > 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. alloc_contig_pages() -> __alloc_contig_pages() -> alloc_contig_range(MIGRATE_MOVABLE) Should always fail when stumbling over MIGRATE_CMA pageblocks IIRC. So we could bail out in that function early if we stumble over any CMA region. -- Thanks, David / dhildenb