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 EB90AC433F5 for ; Tue, 12 Apr 2022 08:06:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3EF9D6B0078; Tue, 12 Apr 2022 04:06:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 377B26B007B; Tue, 12 Apr 2022 04:06:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 218176B007D; Tue, 12 Apr 2022 04:06:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 10D9F6B0078 for ; Tue, 12 Apr 2022 04:06:10 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id CD54D121068 for ; Tue, 12 Apr 2022 08:06:09 +0000 (UTC) X-FDA: 79347494058.03.7D2C328 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 40FAC10000A for ; Tue, 12 Apr 2022 08:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649750768; 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=kVXYFS3onY7D3CiQ2s6YTYii2qpFys84Xut+HVHR5k8=; b=Yd4OmFAHUn70PA0P0HPbs5jDanmUPwdEbCgwXY781vyxExkIo4CJQrY00UF6T+vj4Amr2b HpkXBUHoop3ua/DhbqS6nlp6YaaCY+QJHDTFp3h+88tMQxAS7viHVf7rBuarSCe/IL5KrP 8+SkEPRPR+974VgjRwlRa7GcOnmoB6Q= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-111-kqpAeoE3M8GMfrtOGYfVdQ-1; Tue, 12 Apr 2022 04:06:07 -0400 X-MC-Unique: kqpAeoE3M8GMfrtOGYfVdQ-1 Received: by mail-ej1-f69.google.com with SMTP id nc17-20020a1709071c1100b006e8aeb94fa7so918864ejc.11 for ; Tue, 12 Apr 2022 01:06:07 -0700 (PDT) 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=kVXYFS3onY7D3CiQ2s6YTYii2qpFys84Xut+HVHR5k8=; b=2Tj2FFOXOcS8VWd4bGiuLunGj/QMH2tb198jNQSk1vHAeWCJlYq3RSKmI39qpp/HdG G2/IWTkLtC71rGGo86qt9VCSCLU18kK0f/Mqx50RIspFtpx0W/eYmzRDv4s0xDaKBV5O I4/KAZXyktcq9/bmabxCUTwPawsYeKEfScXlB71HBA1oJIbMHDZ6kbsQ8qbeYp+fE/yC YNQGFM2YcfhE2einV53qMn6ep0iv4/9QpukyQUL87ZBWqzLbzBz/MEb8xxcmh7oyvISo 9ZkerPdOFyVDCkwpFJjyPTtXY8C7odx5J/CO6h8/WwBliAfPnwwNA5LfHfFKqfg7b1hS RqJA== X-Gm-Message-State: AOAM531Xdy2OOYOrpWgvGu+Pzqp5TL62Uk/8/GvsOzjXd9SAUEIvm4TQ UcdKyfhtqw4RlfTfZQA5WKWfANPuastaMuOzLon5KKxlTIpGsaG4QwVQaddNJphR0hZeXG0OFrJ zqa3+pn5IXLY= X-Received: by 2002:a17:906:730c:b0:6e6:c512:49c8 with SMTP id di12-20020a170906730c00b006e6c51249c8mr33701482ejc.405.1649750766462; Tue, 12 Apr 2022 01:06:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxo4u4ew37f1UDJH2s9fF8MD/mnigSDDhKICnyE8nZmBItPQ2UIjbR6/EP8inuN+owHYdapXw== X-Received: by 2002:a17:906:730c:b0:6e6:c512:49c8 with SMTP id di12-20020a170906730c00b006e6c51249c8mr33701441ejc.405.1649750766226; Tue, 12 Apr 2022 01:06:06 -0700 (PDT) Received: from ?IPV6:2003:cb:c707:1800:7c14:16cc:5291:a9f3? (p200300cbc70718007c1416cc5291a9f3.dip0.t-ipconnect.de. [2003:cb:c707:1800:7c14:16cc:5291:a9f3]) by smtp.gmail.com with ESMTPSA id bj13-20020a170906b04d00b006e742719b9fsm10946061ejb.7.2022.04.12.01.06.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 01:06:05 -0700 (PDT) Message-ID: <7d9353f5-2aa4-1e70-deb2-2ff3d2afb396@redhat.com> Date: Tue, 12 Apr 2022 10:06:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [PATCH v3 04/16] mm/rmap: split page_dup_rmap() into page_dup_file_rmap() and page_try_dup_anon_rmap() To: Vlastimil Babka , linux-kernel@vger.kernel.org Cc: Andrew Morton , Hugh Dickins , Linus Torvalds , David Rientjes , Shakeel Butt , John Hubbard , Jason Gunthorpe , Mike Kravetz , Mike Rapoport , Yang Shi , "Kirill A . Shutemov" , Matthew Wilcox , Jann Horn , Michal Hocko , Nadav Amit , Rik van Riel , Roman Gushchin , Andrea Arcangeli , Peter Xu , Donald Dutile , Christoph Hellwig , Oleg Nesterov , Jan Kara , Liang Zhang , Pedro Gomes , Oded Gabbay , linux-mm@kvack.org References: <20220329160440.193848-1-david@redhat.com> <20220329160440.193848-5-david@redhat.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: 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-Server: rspam09 X-Rspam-User: X-Stat-Signature: qh9bkhsmyh8e4cxk5iq8t9krkajkmi36 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Yd4OmFAH; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf05.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=david@redhat.com X-Rspamd-Queue-Id: 40FAC10000A X-HE-Tag: 1649750769-772238 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 11.04.22 20:18, Vlastimil Babka wrote: > On 3/29/22 18:04, David Hildenbrand wrote: >> ... and move the special check for pinned pages into >> page_try_dup_anon_rmap() to prepare for tracking exclusive anonymous >> pages via a new pageflag, clearing it only after making sure that there >> are no GUP pins on the anonymous page. >> >> We really only care about pins on anonymous pages, because they are >> prone to getting replaced in the COW handler once mapped R/O. For !anon >> pages in cow-mappings (!VM_SHARED && VM_MAYWRITE) we shouldn't really >> care about that, at least not that I could come up with an example. >> >> Let's drop the is_cow_mapping() check from page_needs_cow_for_dma(), as we >> know we're dealing with anonymous pages. Also, drop the handling of >> pinned pages from copy_huge_pud() and add a comment if ever supporting >> anonymous pages on the PUD level. >> >> This is a preparation for tracking exclusivity of anonymous pages in >> the rmap code, and disallowing marking a page shared (-> failing to >> duplicate) if there are GUP pins on a page. >> >> Signed-off-by: David Hildenbrand > > Acked-by: Vlastimil Babka > > Nit: > >> --- a/mm/memory.c >> +++ b/mm/memory.c >> @@ -825,7 +825,8 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, >> */ >> get_page(page); >> rss[mm_counter(page)]++; >> - page_dup_rmap(page, false); >> + /* Cannot fail as these pages cannot get pinned. */ >> + BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); > > Should we just call __page_dup_rmap() here? This is block for the condition > is_device_private_entry(), and page_try_dup_anon_rmap() can't return -EBUSY > for is_device_private_page(). Hi Vlastimil, thanks for your review! We want to keep page_try_dup_anon_rmap() here, because we extend page_try_dup_anon_rmap() in patch #12 to properly clear PageAnonExclusive() of there are no GUP pins. Just like with current page_try_dup_anon_rmap(), that can't fail for device private pages. -- Thanks, David / dhildenb