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 6147FC77B75 for ; Thu, 18 May 2023 01:13:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3470900004; Wed, 17 May 2023 21:13:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE49E900003; Wed, 17 May 2023 21:13:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AAC34900004; Wed, 17 May 2023 21:13:14 -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 95531900003 for ; Wed, 17 May 2023 21:13:14 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 296FC120767 for ; Thu, 18 May 2023 01:13:14 +0000 (UTC) X-FDA: 80801602308.06.131D32A Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf21.hostedemail.com (Postfix) with ESMTP id 7F4861C0012 for ; Thu, 18 May 2023 01:13:11 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=httlCJN7; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684372392; a=rsa-sha256; cv=none; b=F5TVEPtt13tqEJxRilRP9qKaWPGcSjoVT6LQUdWofzYaRx0nK8OwVzzmKG34r7Ybpu7Eij Y0vrVSMSkOJeYKMdbxtTtv6oJW2p+YKUYztt5feuWxLC0o1/MbC+0C6xFguGo81S2bcONT yjsCKltXQqlvaTMhO7WOqsOIT5PSbkE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=httlCJN7; spf=pass (imf21.hostedemail.com: domain of ying.huang@intel.com designates 134.134.136.20 as permitted sender) smtp.mailfrom=ying.huang@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684372392; 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=eJQbCoqixSul4G5KcB8jVmT9Kg5lqVZoIAnr6tPMjIE=; b=bKizMDKeAPTa8hIvGFVVIQo3ZgPeF+ftZviJ0L3UxJ6RrQ26CBMOy2YxSQDCvFdWk5fCIT 8vKZ268/ippkoVQUZqlDz7uY2hEus6ZTJEZ2PMEpRdNdTs7GbW3ANeHpOuQBNjMPXrZdXl ttsW3dy9myYwWXUHJllwfCIzhGjaLjM= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684372391; x=1715908391; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=pFd4A2MBW6n8v4ZN7ohmso4i6OszRE3YLaer66HYCrA=; b=httlCJN7nnk/3M59df1QCCcV2WkjpojHX0W2wlhXu8rnJ//X9Xb09+PB GVOx6FTWb22I1ecrHir1j1sbjPw00eAetfYaDrpDNhQr3Yj/KzKZnXloM TCNUhGfGP68AqWtPKwVPffRlZ/gZLrK5PnQxNkAEdVQoKX8SFi1L7b75I 5Ki1NGZlyGPqflYoYG//kbuSBXgTV9JQBhXDGlfEP4QGh42hjJFNmEJq2 SS9JwYXzRgKJ4UHjStPiBb6kfEhb/ZCxVhavbWKWTXxRGZ/Tp+Bj2GG46 eYtH/XcB7P6hDwiS3XFD5u9CoItZSA3YkyuDOujgiKsw2oVaEL9BM7tgu g==; X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="341324967" X-IronPort-AV: E=Sophos;i="5.99,283,1677571200"; d="scan'208";a="341324967" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 18:13:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10713"; a="826175640" X-IronPort-AV: E=Sophos;i="5.99,283,1677571200"; d="scan'208";a="826175640" Received: from yhuang6-desk2.sh.intel.com (HELO yhuang6-desk2.ccr.corp.intel.com) ([10.238.208.55]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2023 18:13:06 -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> Date: Thu, 18 May 2023 09:09:20 +0800 In-Reply-To: (David Hildenbrand's message of "Wed, 17 May 2023 20:32:51 +0200") Message-ID: <87sfbubg3j.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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 7F4861C0012 X-Stat-Signature: bm63oqskatbdgif3389w3ceay39r9mye X-HE-Tag: 1684372391-827506 X-HE-Meta: U2FsdGVkX18lO1wJ+b9I38XtEnxoDiEP2Wu7zITmWJFAKA4RC16ZeTXV12T5IBM/rZ/t5yTzg0ywTNUk/WJtw6T/4iNjDNB9vuV35i81L9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ogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. > We don't want to fail early in case there is a short-term pin that > might go away any moment after we isolated ... that will make the > situation worse for these use cases, especially if MIGRATE_CMA or > ZONE_MOVABLE is involved. Best Regards, Huang, Ying