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.3 required=3.0 tests=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 119E4C0044D for ; Mon, 16 Mar 2020 09:02:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DBF9420658 for ; Mon, 16 Mar 2020 09:02:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DBF9420658 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A1A3A6B0003; Mon, 16 Mar 2020 05:02:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CA826B0005; Mon, 16 Mar 2020 05:02:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 906E96B0007; Mon, 16 Mar 2020 05:02:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 75B816B0003 for ; Mon, 16 Mar 2020 05:02:54 -0400 (EDT) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 4998BDB28 for ; Mon, 16 Mar 2020 09:02:54 +0000 (UTC) X-FDA: 76600635468.04.joke52_36666ba92bb4c X-HE-Tag: joke52_36666ba92bb4c X-Filterd-Recvd-Size: 2033 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Mar 2020 09:02:53 +0000 (UTC) Received: by verein.lst.de (Postfix, from userid 2407) id 02BB668CF0; Mon, 16 Mar 2020 10:02:51 +0100 (CET) Date: Mon, 16 Mar 2020 10:02:50 +0100 From: Christoph Hellwig To: Jason Gunthorpe 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, Christoph Hellwig , Philip Yang , Jason Gunthorpe Subject: Re: [PATCH hmm 2/8] mm/hmm: don't free the cached pgmap while scanning Message-ID: <20200316090250.GB12439@lst.de> References: <20200311183506.3997-1-jgg@ziepe.ca> <20200311183506.3997-3-jgg@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200311183506.3997-3-jgg@ziepe.ca> User-Agent: Mutt/1.5.17 (2007-11-01) 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, Mar 11, 2020 at 03:35:00PM -0300, Jason Gunthorpe wrote: > @@ -694,6 +672,15 @@ long hmm_range_fault(struct hmm_range *range, unsigned int flags) > return -EBUSY; > ret = walk_page_range(mm, hmm_vma_walk.last, range->end, > &hmm_walk_ops, &hmm_vma_walk); > + /* > + * A pgmap is kept cached in the hmm_vma_walk to avoid expensive > + * searching in the probably common case that the pgmap is the > + * same for the entire requested range. > + */ > + if (hmm_vma_walk.pgmap) { > + put_dev_pagemap(hmm_vma_walk.pgmap); > + hmm_vma_walk.pgmap = NULL; > + } > } while (ret == -EBUSY); In which case it should only be put on return, and not for every loop. I still think the right fix is to just delete all the unused and broken pgmap handling code. If we ever need to add it back it can be added in a proper understood and tested way.