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 C2E86C433EF for ; Thu, 20 Jan 2022 18:25:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 487266B0072; Thu, 20 Jan 2022 13:25:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EABE6B009C; Thu, 20 Jan 2022 13:25:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 262386B009E; Thu, 20 Jan 2022 13:25:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0090.hostedemail.com [216.40.44.90]) by kanga.kvack.org (Postfix) with ESMTP id 119206B0072 for ; Thu, 20 Jan 2022 13:25:15 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C14098249980 for ; Thu, 20 Jan 2022 18:25:14 +0000 (UTC) X-FDA: 79051492548.09.5CE7669 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf31.hostedemail.com (Postfix) with ESMTP id 5C0E820044 for ; Thu, 20 Jan 2022 18:25:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642703113; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XlnvntdKeyJn6a4H1tGpGm3klYe/KenHIfs6bqVWGYE=; b=ZEU57fg4hA5rrLVpL8BTfW8TJ4aZ8tATFMNLoUZtGNqbxFhIOZo9ctOcr6iuh6JFoPDGGy po370Zgc8+DhSC1gAQEdiaUmbX0guVF1w6vNTWOyri3Z9WIKo5qpwO67+bvFNF4bEK0EN+ fQQ+w79FjQFC9jher9FmA2ZLRaGOIgk= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-15-Vo2b6b4KNx-FjM9oJJ8pMg-1; Thu, 20 Jan 2022 13:25:11 -0500 X-MC-Unique: Vo2b6b4KNx-FjM9oJJ8pMg-1 Received: by mail-ed1-f70.google.com with SMTP id h11-20020a05640250cb00b003fa024f87c2so6692847edb.4 for ; Thu, 20 Jan 2022 10:25:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=XlnvntdKeyJn6a4H1tGpGm3klYe/KenHIfs6bqVWGYE=; b=aZCnBnoakRyFKLQZjj3qdNR0IF8yxOZaY4V5xLUw2fct5ric1Lq2l/1rBWlBeJLUFe 3SPeE2UXbGf/lsAKPjX0xu1Qf+CNEWpKbL31kQGCDs0lTr7UAAdx3y0dZA3CMEdjhAVC TT4F9ExGSaR5VgZVvy+koZAiTnh2JfvRmHiHemMSWorSDrpW7s7EZTTyiue/VkSuqyM8 52O/iq5DyBsrdWCFrV1CNSmgqbve2FxozOpfMjH2FV00ynS4HlhwkRuogSHPfsqGdJmZ yQ0YGSCcdVfqiTVjP3sMMiMh5Eiug5MTLY8mlXB85cZOLVwjAzalWBLxYPdP3d6hKN5f C+1g== X-Gm-Message-State: AOAM5319yVjMl/84SzUN8qFD9F9M/xENTria1E9L87rdOU6JVZjUKlJ+ ta0S/fXoE5mwztJ5e4xaQoufDQGONX3kFQ3b7k40pNy0+ojOO64q9RH5G7tsi4C4hxahSx4K9CL uib3S++JBdAo= X-Received: by 2002:a05:6402:21d4:: with SMTP id bi20mr385590edb.20.1642703110738; Thu, 20 Jan 2022 10:25:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzL4ltr5hInC42l83cLMKXDoEXStlOPH8wqTyTd77EKcWq1GJwQnQrfyKMpFyZLHhZ4ojwR4A== X-Received: by 2002:a05:6402:21d4:: with SMTP id bi20mr385543edb.20.1642703110497; Thu, 20 Jan 2022 10:25:10 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:5800:eeb:dae2:b1c0:f5d1? (p200300cbc70e58000eebdae2b1c0f5d1.dip0.t-ipconnect.de. [2003:cb:c70e:5800:eeb:dae2:b1c0:f5d1]) by smtp.gmail.com with ESMTPSA id dk3sm1650309edb.33.2022.01.20.10.25.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 20 Jan 2022 10:25:10 -0800 (PST) Message-ID: Date: Thu, 20 Jan 2022 19:25:08 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.4.0 Subject: Re: [RFC][PATCH v2 1/5] mm: Avoid unmapping pinned pages To: Peter Zijlstra , mingo@redhat.com, tglx@linutronix.de, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-api@vger.kernel.org, x86@kernel.org, pjt@google.com, posk@google.com, avagin@google.com, jannh@google.com, tdelisle@uwaterloo.ca, mark.rutland@arm.com, posk@posk.io References: <20220120155517.066795336@infradead.org> <20220120160822.666778608@infradead.org> From: David Hildenbrand Organization: Red Hat In-Reply-To: <20220120160822.666778608@infradead.org> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 5C0E820044 X-Stat-Signature: 43aijg9d58fwp4gw37z9ekd9fiskg5ap Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZEU57fg4; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf31.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Server: rspam03 X-HE-Tag: 1642703113-2177 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 20.01.22 16:55, Peter Zijlstra wrote: > Add a guarantee for Anon pages that pin_user_page*() ensures the > user-mapping of these pages stay preserved. In order to ensure this > all rmap users have been audited: > > vmscan: already fails eviction due to page_maybe_dma_pinned() > > migrate: migration will fail on pinned pages due to > expected_page_refs() not matching, however that is > *after* try_to_migrate() has already destroyed the > user mapping of these pages. Add an early exit for > this case. > > numa-balance: as per the above, pinned pages cannot be migrated, > however numa balancing scanning will happily PROT_NONE > them to get usage information on these pages. Avoid > this for pinned pages. page_maybe_dma_pinned() can race with GUP-fast without mm->write_protect_seq. This is a real problem for vmscan() with concurrent GUP-fast as it can result in R/O mappings of pinned pages and GUP will lose synchronicity to the page table on write faults due to wrong COW. If you're just using it as an optimization, that should work just fine. I assume all migration will freeze the refcount and consequently bail out at that point. In that case, LGTM. -- Thanks, David / dhildenb