Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2703613rwd; Fri, 26 May 2023 10:00:34 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7217DDcx+WlsCDXObFVXNbLmYp6VvnO5cEky1aZEVmPDpa63QOXNgc3YDA1fWXGy9wlI/K X-Received: by 2002:a05:6a21:6da3:b0:f3:33fb:a62b with SMTP id wl35-20020a056a216da300b000f333fba62bmr4831pzb.9.1685120434397; Fri, 26 May 2023 10:00:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685120434; cv=none; d=google.com; s=arc-20160816; b=jbSKuNXKlIlMQ3Va8aD1tw7y9tZ4H/tXEUrSyUIMJMxVpTvXOJZVJig111DkrVde3Y 7sgRpv+cGVPj/gNn5jkfzkIHsqEnQl/DUeyTfTmo1Obu2QRgQHsDgMBs3p6tflvxCmc2 yROj+04FhM09OJbC6aOmzeL4yZAx1zrDs2SdvdLMpV7feMTb80IJN+qH7N1WhXk6Fh+6 +WgM4d9Dguif+osBM3S04PsSk84NTnGGHbE+mlxcLwK4I67pUvuIPsDRPttcwC4VcTlV 48MYkwHiR+iHGKgXVpDsW1rELfC94yCaRPZ01kiqZ3wsXxwm6XRJxmmOBQ25XHgee1sG 37/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DNy7VxTmcB03A0Q+wNNVFlN74rH3YM37TFbDq52wYlY=; b=YLl3NXXcvZ8ScM/hPL2hQnnrbFAK+mcxmDrCyYsTbsNblvEisutE5cxYMsaGapqfvx Iw8yjVcIA1qudS9yb7gCVwiRqCftsnJOpZWXcDMK6cmhMFddHbx6y2JjciuOeRz2p7XK JHDCt3pYtWfMb9zBQmFF+zJmAMItH8ZL2f1dtPO3MOEri2QkECy3rvRkGCDQfVx7WY7R /d1QLpob4oygbZ2/yMGDna83oP20QOYWt7IKuku2mtvCHDyo7gxSfc8HONUJe3pBy4DK dVVXLfH/tQIVcBcnryvYHJHGJreN+cLprK/90yXpwDcu56zGYYdaX5c3SMkm2G1LF9d/ CtYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=sD4Aiswk; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c3-20020a633503000000b00534842e1340si3887785pga.481.2023.05.26.10.00.18; Fri, 26 May 2023 10:00:34 -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=@infradead.org header.s=casper.20170209 header.b=sD4Aiswk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236986AbjEZQon (ORCPT + 99 others); Fri, 26 May 2023 12:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230104AbjEZQok (ORCPT ); Fri, 26 May 2023 12:44:40 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A96EE44 for ; Fri, 26 May 2023 09:44:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=DNy7VxTmcB03A0Q+wNNVFlN74rH3YM37TFbDq52wYlY=; b=sD4AiswkswMTTv28qAmagVF9O9 2cXaPKLaRaADYoRUlDMgpNqwpFsP6H8OhBwqPo7hrZRJBrBRjBzpA7zwuh8WLP1l8IIfXRkUvM86g XuT4eUbWUHZLRrv1GNCqCkoDv42Kf5pELpezci/9Mn3Oyyd2W3o/gw/Q65RnkvreO1YkyyxJbgLEQ z1PbQgBZTJDV9CeaF8d6LjU90REBzLdPxPmQ2CpvWdkXSIXUPLUNLrk3bk1advZr/tuwD0AGr7JHh w0WDneSfDXIBmBBOpoVV8/OUyprcwCpbuz3W5TRG8GUUVLd+dJJjehf9F9wkqKVsOcll/1EIQxf+a XO+ws+/A==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q2aY4-002xqz-Qd; Fri, 26 May 2023 16:44:16 +0000 Date: Fri, 26 May 2023 17:44:16 +0100 From: Matthew Wilcox To: Khalid Aziz Cc: Steven Sistare , akpm@linux-foundation.org, david@redhat.com, ying.huang@intel.com, mgorman@techsingularity.net, baolin.wang@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Khalid Aziz Subject: Re: [PATCH v4] mm, compaction: Skip all non-migratable pages during scan Message-ID: References: <20230525191507.160076-1-khalid.aziz@oracle.com> <60367660-f4a3-06dc-4d17-4dbdc733ef74@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <60367660-f4a3-06dc-4d17-4dbdc733ef74@oracle.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 On Fri, May 26, 2023 at 09:44:34AM -0600, Khalid Aziz wrote: > > Oh, I think I found it! pin_user_pages_remote() is called by > > vaddr_get_pfns(). If these are the pages you're concerned about, > > then the efficient way to do what you want is simply to call > > folio_maybe_dma_pinned(). Far more efficient than the current mess > > of total_mapcount(). > > vfio pinned pages triggered this change. Wouldn't checking refcounts against > mapcount provide a more generalized way of detecting non-migratable pages? Well, you changed the comment to say that we were concerned about long-term pins. If we are, than folio_maybe_dma_pinned() is how to test for long-term pins. If we want to skip pages which are short-term pinned, then we need to not change the comment, and keep using mapcount/refcount differences.