Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9203657ybi; Tue, 23 Jul 2019 23:53:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyJ6dUS1kMFtL3WpggIy5shgSRRPI/R5DkPsUO+0qvAcYFE5vga7l83xUnwO66tbX+3P4hz X-Received: by 2002:a65:44cb:: with SMTP id g11mr34638968pgs.288.1563951236210; Tue, 23 Jul 2019 23:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563951236; cv=none; d=google.com; s=arc-20160816; b=1IasK9H7zhrYPKGTLhU2I2pY+UB7k3Tx08sRsecgu2i3bzbJt8LoakiPTSX5iyRau4 9WT5Y6NQdi/AtkrsB7fHJ7t31RhUQBTfS1e6JJ+Ya2kOe+8TNqivNJ6KPr/tKCbXcEly Gs9W6JxEWgBVeLG71sBocaCeX/HVXvzZ+oib5OYRhmoXjEoCzuSXKIEumsMUopW4h2XH TDh/4fmVhZUluXygDjhm4Ho3Pnc1pcZd6gqv1LSB9C+vuBZrtZShIc0q1EkbygBR52U2 +YsakM23v7qS/X66X4qxVbe8WcIe+9H65oc5jDXwr70Cm16xm46EDm6LBvjqdJfw2kXS Mp3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=gngCecV7WjLyNPhRBdXWgOJiVdOGsSnio12VPlIEw78=; b=g05yT+Td8YN4njJx1tIY+qYc+hKfNApzaS/Fd5vWCoVS4yWm5zCvdv3h39fFUpDGwp VxMB7zCRXyvtkI8lyEP9ZBSWwQzykI3stl4lXg/mnMtR/SBLYG7XKRVh54t1WQX9y0KO IGYKBfRU/CAXF/YwJVfKj50TVscl/ez5JJn4tCVEJ+LCI4JYMPtJrTpIghLZtzXl4b8O Dc9ybKqNuqGQzPyHxQKmorhCCMedTDSKPliV6RQkjPHTXZP7yDY2JaqzlPtfXR2u+zgN 1XNLurRupi/jeFviUKE8cwe8yjUXO6R3zx+AYFHOar6RU2tDn3nK4hh+FOnau1s7MLyW pztg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si14184920plb.62.2019.07.23.23.53.41; Tue, 23 Jul 2019 23:53:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726303AbfGXGvs (ORCPT + 99 others); Wed, 24 Jul 2019 02:51:48 -0400 Received: from verein.lst.de ([213.95.11.211]:48150 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725909AbfGXGvs (ORCPT ); Wed, 24 Jul 2019 02:51:48 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 6DD4768B02; Wed, 24 Jul 2019 08:51:46 +0200 (CEST) Date: Wed, 24 Jul 2019 08:51:46 +0200 From: Christoph Hellwig To: Ralph Campbell Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?iso-8859-1?B?Suly9G1l?= Glisse , Jason Gunthorpe , Christoph Hellwig Subject: Re: [PATCH 2/2] mm/hmm: make full use of walk_page_range() Message-ID: <20190724065146.GA2061@lst.de> References: <20190723233016.26403-1-rcampbell@nvidia.com> <20190723233016.26403-3-rcampbell@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190723233016.26403-3-rcampbell@nvidia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 23, 2019 at 04:30:16PM -0700, Ralph Campbell wrote: > hmm_range_snapshot() and hmm_range_fault() both call find_vma() and > walk_page_range() in a loop. This is unnecessary duplication since > walk_page_range() calls find_vma() in a loop already. > Simplify hmm_range_snapshot() and hmm_range_fault() by defining a > walk_test() callback function to filter unhandled vmas. I like the approach a lot! But we really need to sort out the duplication between hmm_range_fault and hmm_range_snapshot first, as they are basically the same code. I have patches here: http://git.infradead.org/users/hch/misc.git/commitdiff/a34ccd30ee8a8a3111d9e91711c12901ed7dea74 http://git.infradead.org/users/hch/misc.git/commitdiff/81f442ebac7170815af7770a1efa9c4ab662137e That being said we don't really have any users for the snapshot mode or non-blocking faults, and I don't see any in the immediate pipeline either. It might actually be a better idea to just kill that stuff off for now until we have a user, as code without users is per definition untested and will just bitrot and break. > + const unsigned long device_vma = VM_IO | VM_PFNMAP | VM_MIXEDMAP; > + struct hmm_vma_walk *hmm_vma_walk = walk->private; > + struct hmm_range *range = hmm_vma_walk->range; > + struct vm_area_struct *vma = walk->vma; > + > + /* If range is no longer valid, force retry. */ > + if (!range->valid) > + return -EBUSY; > + > + if (vma->vm_flags & device_vma) Can we just kill off this odd device_vma variable? if (vma->vm_flags & (VM_IO | VM_PFNMAP | VM_MIXEDMAP)) and maybe add a comment on why we are skipping them (because they don't have struct page backing I guess..)