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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE5D0C433EF for ; Wed, 29 Sep 2021 22:47:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 85B9561425 for ; Wed, 29 Sep 2021 22:47:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 85B9561425 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 170B6940064; Wed, 29 Sep 2021 18:47:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1203694003A; Wed, 29 Sep 2021 18:47:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01032940064; Wed, 29 Sep 2021 18:47:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0121.hostedemail.com [216.40.44.121]) by kanga.kvack.org (Postfix) with ESMTP id E6E8594003A for ; Wed, 29 Sep 2021 18:47:24 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A0EBD183BCDA8 for ; Wed, 29 Sep 2021 22:47:24 +0000 (UTC) X-FDA: 78642098808.02.72316A2 Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf09.hostedemail.com (Postfix) with ESMTP id 54B3B3000117 for ; Wed, 29 Sep 2021 22:47:24 +0000 (UTC) Received: by mail-lf1-f49.google.com with SMTP id b15so16964834lfe.7 for ; Wed, 29 Sep 2021 15:47:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=I+ylkTo++i3WR0CEnKkRQqmxVnZ9S2+8fkiGjE4czak=; b=RpSZ+oEDTAW5ue8DRRjayHgpxplrvk/GAGMhemHc3Csny/g4c7RVC84IQbqStZJbrT lFAg5iaeld6pUnJ353UZFwSzX4o5TaYjI4L22LItzJPWlHJaMiL+rRKBhbvVwVlsesju 8BY42Mgz3QAPsNb8xE3zQfAoWJLVdKoYQKOcY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=I+ylkTo++i3WR0CEnKkRQqmxVnZ9S2+8fkiGjE4czak=; b=4LSXJzUH8c3ADVVglzMxc24OMuE+9WGQF3SACBqSuDmjBK5Dy0bYiKvS5fz1Ib5ts1 gz7wkpTv9JrpbpmJqpd32zDUYQO2B+7UhgPICP1PPyt4dlrNKK5QTf2pajLBNNMWZiwu 1rpMyJsTa8NX9JZPAa51RKZM5g8E6D77s+JkMbCyMlYXMxNYoSgCqj5bJid0ACEl0dZu g3S4VDe7lN/RPxBvp/fQoD98Jt8E4aT9RoHy5QibHTWlSFP+g2wKKYwSUv2HMcO57HNA NkTPHZs9lGdT/VUj6E1GLFdru+PUgKDrMyIFa2pP9wkgIh8Sp5Ng+4Er8GeQs6/LWDbV 7F4A== X-Gm-Message-State: AOAM5322WqsGzl/0tCjcfBVTkiQVpC1SafyO9frKKWgG53ooxfA8kglu v6oP1kplrRqwJdcgD48qQWg6OucOEN0JRRsKOBs= X-Google-Smtp-Source: ABdhPJwV+mROFL8AGPy61CR+zSy5aGG2pUM/RbCTnpXYTT4YS80vDr55ihkXDdpAu/wgQ760ERF4qA== X-Received: by 2002:a05:6512:31c6:: with SMTP id j6mr2271304lfe.436.1632955642156; Wed, 29 Sep 2021 15:47:22 -0700 (PDT) Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com. [209.85.167.50]) by smtp.gmail.com with ESMTPSA id m23sm128235lji.132.2021.09.29.15.47.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Sep 2021 15:47:21 -0700 (PDT) Received: by mail-lf1-f50.google.com with SMTP id z24so17007840lfu.13 for ; Wed, 29 Sep 2021 15:47:21 -0700 (PDT) X-Received: by 2002:a19:ef01:: with SMTP id n1mr2352870lfh.150.1632955641338; Wed, 29 Sep 2021 15:47:21 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Wed, 29 Sep 2021 15:47:05 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Possible race with page_maybe_dma_pinned? To: Peter Xu Cc: Linux MM Mailing List , Jason Gunthorpe , John Hubbard , Jan Kara , Andrew Morton , Andrea Arcangeli Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 54B3B3000117 X-Stat-Signature: 6bjes9aj8sqpg1pnyqixkptybdsqc5u5 Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=google header.b=RpSZ+oED; spf=pass (imf09.hostedemail.com: domain of torvalds@linuxfoundation.org designates 209.85.167.49 as permitted sender) smtp.mailfrom=torvalds@linuxfoundation.org; dmarc=none X-Rspamd-Server: rspam06 X-HE-Tag: 1632955644-196760 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 Wed, Sep 29, 2021 at 12:57 PM Peter Xu wrote: > > Now we have 3 callers of page_maybe_dma_pinned(): > > 1. page_needs_cow_for_dma > 2. pte_is_pinned > 3. shrink_page_list > > The 1st one is good as it takes the seqlock for write properly. The 2nd & 3rd > are missing, we may need to add them. Well, the pte_is_pinned() case at least could do the seqlock in clear_soft_dirty() - it has the vma and mm available. The page shrinker has always been problematic since it doesn't have the vm (and by "always" I mean "modern times" - long ago we used to scan virtually, in the days before rmap) One option might be for fast-gup to give up on locked pages. I think the page lock is the only thing that shrink_page_list() serializes with. Linus