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 C258BC433F5 for ; Fri, 21 Jan 2022 08:00:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FA0D6B007E; Fri, 21 Jan 2022 03:00:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5833E6B0080; Fri, 21 Jan 2022 03:00:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 44BB76B0081; Fri, 21 Jan 2022 03:00:00 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0198.hostedemail.com [216.40.44.198]) by kanga.kvack.org (Postfix) with ESMTP id 368A36B007E for ; Fri, 21 Jan 2022 03:00:00 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id DCB18181CB2DA for ; Fri, 21 Jan 2022 07:59:59 +0000 (UTC) X-FDA: 79053545718.05.7BD9133 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf28.hostedemail.com (Postfix) with ESMTP id 75481C0002 for ; Fri, 21 Jan 2022 07:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=lM96gxE5Zvd4KW4P3zg/HRQmsMNlTVeN2Nd1koQYNu0=; b=YmPjgbo+hz7cUwXro8Ro7FtcZk 7OcXA3deT6tbo/KjioKqugUMGejB/qwRcuUZ+kzw1bQsrNt2GcQzylzIS0ym0bonp5WFfBihTC0PD wFo2EPBnVbIY7jn/BfL5m947SGp9OQ50nUhsMk2OpsH0Ce1XlZtnvj02wLBdDYXw6+fA6H96kjF+u ldftHUnIVWas7ZrkXmaPMBz5SRgsALt8ggiLPJdQ6xP2GmbiQ4hcF13YE4iCxfvGhIVfU3mCcoW+Y /QUk0qvEwVjhU1NNmLLUQiQfTqEdVxupynRs8+QBlVkJhjJr2WwyMMOQw6xZMcAp7QopZTZ0uUrUI CCRvrzWQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAopk-002XY0-7a; Fri, 21 Jan 2022 07:59:44 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 51F19984B76; Fri, 21 Jan 2022 08:59:43 +0100 (CET) Date: Fri, 21 Jan 2022 08:59:43 +0100 From: Peter Zijlstra To: Nadav Amit Cc: Ingo Molnar , Thomas Gleixner , juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, Steven Rostedt , bsegall@google.com, Mel Gorman , bristot@redhat.com, Linux Kernel Mailing List , Linux-MM , linux-api@vger.kernel.org, X86 ML , pjt@google.com, posk@google.com, avagin@google.com, Jann Horn , tdelisle@uwaterloo.ca, mark.rutland@arm.com, posk@posk.io Subject: Re: [RFC][PATCH v2 1/5] mm: Avoid unmapping pinned pages Message-ID: <20220121075943.GB20638@worktop.programming.kicks-ass.net> References: <20220120155517.066795336@infradead.org> <20220120160822.666778608@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=YmPjgbo+; dmarc=none; spf=none (imf28.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org X-Stat-Signature: 31gufhmsu8wwojofp6k5zqk6awwp18ug X-Rspamd-Queue-Id: 75481C0002 X-Rspamd-Server: rspam12 X-HE-Tag: 1642751999-330587 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jan 20, 2022 at 10:03:44AM -0800, Nadav Amit wrote: > > --- a/mm/mprotect.c > > +++ b/mm/mprotect.c > > @@ -106,6 +106,12 @@ static unsigned long change_pte_range(st > > continue; > > > > /* > > + * Can't migrate pinned pages, avoid touching them. > > + */ > > + if (page_maybe_dma_pinned(page)) > > + continue; > > + > > + /* > > > > I have a similar problem with userfaultfd changing protection for > DMA-pinned pages. For userfaultfd it is important to know how many > pages were actually modified. > > I am working on a vectored UFFDIO_WRITEPROTECTV that aborts once > a pinned page is encountered, but also returns the number of pages > that were properly protected. I still need to do some work to > send patches for that as it requires further changes (to return > the number of pages that were handled). > > But for the matter of your patch, is it possible to make this > test generic (not migration specific) and rely on a new flag in > cp_flags? I can of course make this change later if you prefer it > this way. I have no objection to making it apply more widely, but I'm currently only interested in the rmap users. If userspace does mprotect() on it's own pages, it gets to keep whatever pieces are the result of that.