Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2498321rwd; Sun, 21 May 2023 22:58:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5XLzvOy0GbyHztNA2EMJAA3aHpc7s5n4tYFaMqS9azU6nXOxysdRFSAlJF6715eGmgqvUq X-Received: by 2002:a05:6a20:c886:b0:106:5dff:5dc6 with SMTP id hb6-20020a056a20c88600b001065dff5dc6mr9348278pzb.16.1684735126543; Sun, 21 May 2023 22:58:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684735126; cv=none; d=google.com; s=arc-20160816; b=0B2EtcVBCVuW0LpISP3ZQtQlJ6Uiw5s3rCDhfst2SEDJA6iJfVhWKlNLBqVvNPKYiS wZZk/B6O2hYB+txvC0zWTOsFYHwZQe3LAlbDVUNkAbXsJ9YSSODx/v5wNmhBcbrqSMh6 Iw/+diXZpYVeUJrVl02uYaXs7KhleV0LDjmJc0/8fQzjmKMl//fM0JyaLqv3XPsw8YZj xccd9s8eWq8uoaHNMgRmUK9l/LsC+cJlqBu86UHtP97s0ETvfVocm/VeAEOyG4HIm0EG zykhKK+1QN3tjBx9p41/2JPfgKromnUkjlLzuaj/HsSJ7EQMTmhfcia/laXQZERGnK2B K37w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=SfmvEfRz1S8h5FlxQK1YhvOFzmULZvD3kJS9sAB5Go4=; b=P8Fu/m5Ks6L6uXw9CqXDTT3jJ3iUdk+c+jTEUQWducnyxPfD91ervmd1ZkWghUjgKN 6jIAklYKXYmLUAREp0likJnsiG7VG6l8v2M6eW3hvGYyXm+72kvDk9oLXHcFVniIJba9 48evTWaAY1koyMmhYrqPtsuwmsxVS2vw8Z50g8Fm+243yYd4/dlCO+tNa8BjftbJIGaI E4GLAtB69+zUgkOax0mv/ni2IyrpNLTWAE5I0z3E17jem9ykSaNZ6ePXsQvrw/kxlcDS uXhx6iRYcgcGqCEKYXL+zzfq29v28xeEuoWMAtfJDlxwrrolPOzBIhaKpUJRjQ5S2Kdt Kc7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QvE3N5b0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k191-20020a6384c8000000b005347d6bd7edsi4123716pgd.400.2023.05.21.22.58.32; Sun, 21 May 2023 22:58:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QvE3N5b0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229671AbjEVF5O (ORCPT + 99 others); Mon, 22 May 2023 01:57:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbjEVF5M (ORCPT ); Mon, 22 May 2023 01:57:12 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDC34CE for ; Sun, 21 May 2023 22:57:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684735031; x=1716271031; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=tOMcNfhocZCO/GNSExZGCChK9wg74/hawJud+TAllGI=; b=QvE3N5b0AYeUi044/e9D+WiQIse6wqArQwLEDu5cZuSt44lF08TfN5ON /jny0IODGEv4vFapup+SEw0U9jEBLiqL9tg9TFJG2m20hd48o4i0bbO9r IhK5lZFterW3Bw8qqghNh8a/4YSje0oc22QDiIOue3PEoXc1983pA7AT4 u62lV1rLVn3qkYOc0yQN6QMX9Z5b1kK+Uz2CP7U6/kb3gDcDqH7mT4dRx fxR89ow8PcFftnSB18DmXo+aYTgUyShtjo4DrFaM/7GZuu1hxtzOipi3q meCktHUxJC0zmJ0eK1IdRvrelqxI9fa+Cstx1PwoqsnA5YSxESvtrqfmx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="332439331" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="332439331" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2023 22:57:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10717"; a="736286283" X-IronPort-AV: E=Sophos;i="6.00,183,1681196400"; d="scan'208";a="736286283" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2023 22:57:08 -0700 From: "Huang, Ying" To: David Hildenbrand Cc: Khalid Aziz , akpm@linux-foundation.org, willy@infradead.org, steven.sistare@oracle.com, mgorman@techsingularity.net, khalid@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3] mm, compaction: Skip all non-migratable pages during scan References: <20230517161555.84776-1-khalid.aziz@oracle.com> <87sfbubg3j.fsf@yhuang6-desk2.ccr.corp.intel.com> <5f43a17c-94a0-4bff-b451-e5014de36ed9@redhat.com> Date: Mon, 22 May 2023 13:55:51 +0800 In-Reply-To: <5f43a17c-94a0-4bff-b451-e5014de36ed9@redhat.com> (David Hildenbrand's message of "Fri, 19 May 2023 11:51:00 +0200") Message-ID: <875y8k3o60.fsf@yhuang6-desk2.ccr.corp.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=ascii X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org David Hildenbrand writes: > On 18.05.23 03:09, Huang, Ying wrote: >> David Hildenbrand writes: >> >>> On 17.05.23 18:15, Khalid Aziz wrote: >>>> Pages pinned in memory through extra refcounts can not be migrated. >>>> Currently as isolate_migratepages_block() scans pages for >>>> compaction, it skips any pinned anonymous pages. All non-migratable >>>> pages should be skipped and not just the anonymous pinned pages. >>>> This patch adds a check for extra refcounts on a page to determine >>>> if the page can be migrated. This was seen as a real issue on a >>>> customer workload where a large number of pages were pinned by vfio >>>> on the host and any attempts to allocate hugepages resulted in >>>> significant amount of cpu time spent in either direct compaction or >>>> in kcompactd scanning vfio pinned pages over and over again that can >>>> not be migrated. >>> >>> How will this change affect alloc_contig_range(), such as used for CMA >>> allocations or virtio-mem? alloc_contig_range() ends up calling >>> isolate_migratepages_range() -> isolate_migratepages_block(). >> IIUC, cc->alloc_contig can be used to distinguish contiguous >> allocation >> and compaction. And, from the original commit which introduced >> anonymous pages skipping (commit 119d6d59dcc0 ("mm, compaction: avoid >> isolating pinned pages ")) and this patch, large number of migration >> failure during compaction causes real issue too. So, I suggest to use >> cc->alloc_contig here. > > Agreed. I further wonder if we want to special-case the !alloc_contig > case also for MIGRATE_CMA and ZONE_MOVABLE, where we cannot have > longterm page pinnings (e.g., vfio pinned pages). This makes sense. The skipping is more accurate in this way. Best Regards, Huang, Ying