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 X-Spam-Level: X-Spam-Status: No, score=-2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F56C0044D for ; Mon, 16 Mar 2020 12:56:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3EAF6205ED for ; Mon, 16 Mar 2020 12:56:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="bCMGba0B" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3EAF6205ED Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DFDC26B0003; Mon, 16 Mar 2020 08:56:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D867E6B0005; Mon, 16 Mar 2020 08:56:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4F5D6B0007; Mon, 16 Mar 2020 08:56:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0168.hostedemail.com [216.40.44.168]) by kanga.kvack.org (Postfix) with ESMTP id A95786B0003 for ; Mon, 16 Mar 2020 08:56:21 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7170EC5DE for ; Mon, 16 Mar 2020 12:56:21 +0000 (UTC) X-FDA: 76601223762.13.wall92_3775bd61e4336 X-HE-Tag: wall92_3775bd61e4336 X-Filterd-Recvd-Size: 5022 Received: from mail-qv1-f66.google.com (mail-qv1-f66.google.com [209.85.219.66]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 12:56:20 +0000 (UTC) Received: by mail-qv1-f66.google.com with SMTP id n1so4941483qvz.4 for ; Mon, 16 Mar 2020 05:56:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=9afDjhZOSyJUHdf1GkVOxnQKnlyCaNPiE4Hy3XHDSEs=; b=bCMGba0BzNqcZVGrUScR5wOIQdfIMNMh+BS9C/6fqIBz5nk0TM7qUVTwELz0nIVulu 1AHU6ziIdLeUPbQmfDJiZe/LPOnZ6Rb1ggGHNQHCGy4QRD3nLhatQmGOuY4ITpZKRP9l FpSNVZxEnPpiq1I+RoP8x4T0aCI2IeE6CxEIA5yAgylAydxVHRnZeX33BtAMHWSUv9FZ cnsZRAx9FtXra5OfQ5fXNx6mec2VIjDhStLpIsXeS4MqLtPVqzlYSMxe2FkBvhRz5iWJ UI6J/+5Ogq87iPM2RVJZi0DfCrHtLmiD9H3ZTVP31/72FFHLDtZyELRonIfX5eOMf/WF kSJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=9afDjhZOSyJUHdf1GkVOxnQKnlyCaNPiE4Hy3XHDSEs=; b=lwlVO7oJk37gKqwwtlljkWg6faoTtEZgtfezpBuuk+Z+MY40kUnco8XvgIzMYhJjWR cQdJH2+330D4ikPmUtjKzvIcxVR0vntQwujWf1TiPKU0uemRuxCjZrLqHiU1RTn2V9p8 dkG8mP1ZKxW5pTMkV8Qz7uleRhjBuLvOD8RWFGIChT+HwJJxTxeigyUZOyGKV1uZSFFe gNDUwrSB9+1dwmf5xd79Z2Vb4am8pIblMxFXF3PTtJWLlBbUjcrOcIQ8z3yQAo8wyfBe Eh873Wo5U0FLK0+5oleOCamafmC2DeIz6RfzrQiaTys6MzDxaS4H7sgCF4sSEMOZkEHu 01hw== X-Gm-Message-State: ANhLgQ0T51G1XUPczgS6eMl0aleDLuj2fmO5vaXlfgZX55AoeaVcGoIh fTf+PUFISDH79j7DegTG+GE1sQ== X-Google-Smtp-Source: ADFU+vtUduROMwqOJJyWfZqPAANVdbItSWyPg2bF11scOuNemFeQ0dw4lzjtAU2ST+aV6YNENmxwdw== X-Received: by 2002:a0c:b203:: with SMTP id x3mr24403145qvd.197.1584363380456; Mon, 16 Mar 2020 05:56:20 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-142-68-57-212.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.68.57.212]) by smtp.gmail.com with ESMTPSA id 82sm19477339qkd.62.2020.03.16.05.56.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Mar 2020 05:56:19 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1jDpI3-0003yQ-BR; Mon, 16 Mar 2020 09:56:19 -0300 Date: Mon, 16 Mar 2020 09:56:19 -0300 From: Jason Gunthorpe To: Christoph Hellwig Cc: Jerome Glisse , Ralph Campbell , Felix.Kuehling@amd.com, linux-mm@kvack.org, John Hubbard , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Philip Yang , Steven Price Subject: Re: [PATCH hmm 3/8] mm/hmm: do not call hmm_vma_walk_hole() while holding a spinlock Message-ID: <20200316125619.GD20941@ziepe.ca> References: <20200311183506.3997-1-jgg@ziepe.ca> <20200311183506.3997-4-jgg@ziepe.ca> <20200316090503.GC12439@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200316090503.GC12439@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) 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 Mon, Mar 16, 2020 at 10:05:03AM +0100, Christoph Hellwig wrote: > On Wed, Mar 11, 2020 at 03:35:01PM -0300, Jason Gunthorpe wrote: > > From: Jason Gunthorpe > > > > This eventually calls into handle_mm_fault() which is a sleeping function. > > Release the lock first. > > > > hmm_vma_walk_hole() does not touch the contents of the PUD, so it does not > > need the lock. > > So how did this manage to not be noticed before? I'm still struggling a bit with how this PUD stuff works.. However AFAICT: 1) The first hunk around pud_none() is actualy covering a race. In the non-race case the page walker will directly call hmm_vma_walk_hole() for pud_none so it would be very hard to hit this 2) I'm not 100% sure, but I think pud_present() == pud_none(), as there is no swap entry for PUD I don't know what a non-present but non-none entry is or how to create one. This is possibly dead code due to #1 3) To hit hmm_range_need_fault() requesting fault you would need a read-only huge PUD and a fault requesting write. I suspect creating a read only huge PUD entry is very rare - not something someone would deliberately construct. 4) To even trigger the PUD flow at all you need the 1G THP or the special 1G DAX pages which I strongly suspect people are not testing with. > The fix looks fine assuming we want something backportable before > starting the cleanups: I found it easier to make the other cleanup patches make sense if they didn't introduce all kinds of new logic too.. Thanks, Jason