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 BBF3BC19F2D for ; Tue, 9 Aug 2022 14:43:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 176746B0072; Tue, 9 Aug 2022 10:43:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 126246B0073; Tue, 9 Aug 2022 10:43:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F30126B0074; Tue, 9 Aug 2022 10:43:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E2EC56B0072 for ; Tue, 9 Aug 2022 10:43:55 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id BA50B1C680D for ; Tue, 9 Aug 2022 14:43:55 +0000 (UTC) X-FDA: 79780323630.04.CFB00E2 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 3FBF118014F for ; Tue, 9 Aug 2022 14:43:54 +0000 (UTC) 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=7z/JIUVgUhFXekW4Gduj7+h/qYJwWZYYv/506cYfRO4=; b=X6wAY4JSpD1MsTGMIps4uXR5+K fdixl0iqHE7B7Bon+LpUoDec++73sL08sVAJRflcDWBhGUKQa8ssHAXqitz6BesQEJwCGDSJHf2gq /Cmeh9Fsn1lZS49+AAVsTvAtwc6keu7assWYRuztEb4S65hHqOWgvQMKocYlTHlXiiZ1If8VI/rtS kXL9KxSaom4Gy3hdgPu2uZDhq1occseSvi7Vf42G6V7Pymb/IULH77VbXKyfLpw0hNaVMHHx+OXm+ +K6zIVjZdNuuSgcmm+TEVkxHzp2rq1X/+XO+HyA3a9s13jDLGdWhuBZGrA7deQQsmZmP/PD7ADVke jBNGfMtA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1oLQSL-00FU2x-6I; Tue, 09 Aug 2022 14:43:41 +0000 Date: Tue, 9 Aug 2022 15:43:41 +0100 From: Matthew Wilcox To: Felix Kuehling Cc: Alex Williamson , alex.sierra@amd.com, akpm@linux-foundation.org, hch@lst.de, apopple@nvidia.com, david@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: re-allow pinning of zero pfns (again) Message-ID: References: <166002010021.381133.11357879752637949308.stgit@omen> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=X6wAY4JS; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660056234; a=rsa-sha256; cv=none; b=gZm/6cSvAQjM/Khd4MWgHNmiCHc8PaczlDGBrvKNQPaQ7d9ln85WfUEDlj4YEJf+gsS1xR GDr/pcQ2qjnAMGm1bzyHDC88fbFvb6Afgl4uF3OKrxMFkD3J9+fDDQ0cPYxlqmvAG/wdrf S0N+v6pTHEeq+Me655vM1/xnWdErQNc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660056234; 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=7z/JIUVgUhFXekW4Gduj7+h/qYJwWZYYv/506cYfRO4=; b=0yXvDuhTisoDSbG71hT1au9QqnrsyA6K/hof44lAQVxRfQ3S9NnWOvNo07iqBhOAOS1B/U aRNBbzh1GCN7h43xmEvOevGFYVBt/p2ABaUuDyJbV02JKqtUsHdFYPfs1Os/x2N4KuKshH vgndYk381Iu6FOnUe/0ef7+ZD7532y0= X-Stat-Signature: eggy179r4n6tkgu34gjmjmxenco5pbx5 X-Rspam-User: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3FBF118014F Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=X6wAY4JS; spf=none (imf06.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1660056234-861865 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 Tue, Aug 09, 2022 at 10:14:12AM -0400, Felix Kuehling wrote: > Am 2022-08-09 um 08:31 schrieb Matthew Wilcox: > > On Mon, Aug 08, 2022 at 10:42:24PM -0600, Alex Williamson wrote: > > > The below referenced commit makes the same error as 1c563432588d ("mm: fix > > > is_pinnable_page against a cma page"), re-interpreting the logic to exclude > > > pinning of the zero page, which breaks device assignment with vfio. > > Perhaps we need to admit we're not as good at boolean logic as we think > > we are. > > > > if (is_device_coherent_page(page)) > > return false; > > if (is_zone_movable_page(page)) > > return false; > > return is_zero_pfn(page_to_pfn(page)); > > > > (or whatever the right logic is ... I just woke up and I'm having > > trouble parsing it). > > This implies an assumption that zero-page is never device-coherent or > moveable, which is probably true, but not part of the original condition. A > more formally correct rewrite would be: > > if (is_zero_pfn(page_to_pfn(page))) > return true; > if (is_device_coherent_page(page)) > return false; > return !is_zone_moveable_page(page); It's definitely true that the zero page is never device-coherent, nor movable. Moreover, we want to avoid calling page_to_pfn() if we can. So it should be the last condition that we check.