Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5534985ybh; Wed, 7 Aug 2019 07:32:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqwXQCh0wO/9J73XG0bPyIgqNkSyETr8ZvaMkYvwT3qomn/vF/7Gbe2A9FGOXclPzOh8HUKk X-Received: by 2002:aa7:8dcc:: with SMTP id j12mr9662807pfr.137.1565188341670; Wed, 07 Aug 2019 07:32:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565188341; cv=none; d=google.com; s=arc-20160816; b=yjyIN1wJJQwU5q+Ad/uy/rY+Gps/496M/lx7lVE11EDvHhq4Yf29Xc19kYV0nLLMp5 Yyd5oPZEcezvj7Mg2iOywdtkoqDSnQMWhcAuDD0sYKtWg5/ezF7MKR3mB5xJI7tCOzxB YMOZp0eUhM54Ei0JcdaJS/gzERqdsvGzWai0Nd7lBCX4dVh7IBtDrkz+2kEtuBu5UCyd G3PemDa6HWrbUn6MmA6Gsnr4fIgbnXOwLtPlK/tJz/82oKzSJT1fX3PtySB5dQ867Jk+ jfDKNAlP0i+bLnoAhs0itwItdHqdbmHqCN685Kh5ernnJJ46TBkZYzG5nvv0TOjkKo// nG/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=OmNZf17ZKGN6g8JA/2I7YchHz7R0kl+zAp4OE7QfRr8=; b=PbvfkKGwR3P79Ekcbj1xdJr+NIg2/u1OHBSN628fk8dQSZOu2L2BcXwREnjjAY9Njn gaznPD0KdFj5A+VWKH7KzH5XyhjM5Fl4V08wAmJkAIF8it4zk8Xf6a3T2ijs1igAsZAq jToknP7IV1/owCKaWBPe2mjbOBYjcG6ZsDTHwTFMbF6l8WePV3hEFPrdmKG7Mwtz7R/Z G2wDfLRGIbYDGTobBFxO4zK2xXs7YuNxjBi/59YXNbwieg9AUR8GXxSEskCaoYKNf0wB DWeHc6+TzMT/r990CbA/dgAKKjQy5/WF0ZdXkkejUvaOe7B4ztMO/jK69Ev2NnNq+cUI larw== 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 d5si44973023pls.233.2019.08.07.07.32.05; Wed, 07 Aug 2019 07:32:21 -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 S1730036AbfHGOam (ORCPT + 99 others); Wed, 7 Aug 2019 10:30:42 -0400 Received: from foss.arm.com ([217.140.110.172]:49438 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729808AbfHGOam (ORCPT ); Wed, 7 Aug 2019 10:30:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5B8EE344; Wed, 7 Aug 2019 07:30:41 -0700 (PDT) Received: from [10.1.196.133] (e112269-lin.cambridge.arm.com [10.1.196.133]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C3CB23F706; Wed, 7 Aug 2019 07:30:39 -0700 (PDT) Subject: Re: drm pull for v5.3-rc1 To: Matthew Wilcox , Christoph Hellwig Cc: Linus Torvalds , =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= , Dave Airlie , Thomas Hellstrom , Daniel Vetter , LKML , dri-devel , Jerome Glisse , Jason Gunthorpe , Andrew Morton , Linux-MM References: <48890b55-afc5-ced8-5913-5a755ce6c1ab@shipmail.org> <20190806073831.GA26668@infradead.org> <20190806190937.GD30179@bombadil.infradead.org> <20190807064000.GC6002@infradead.org> <20190807141517.GA5482@bombadil.infradead.org> From: Steven Price Message-ID: <62cbe523-e8a4-cdfd-90c2-80260cefa5de@arm.com> Date: Wed, 7 Aug 2019 15:30:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190807141517.GA5482@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/08/2019 15:15, Matthew Wilcox wrote: > On Tue, Aug 06, 2019 at 11:40:00PM -0700, Christoph Hellwig wrote: >> On Tue, Aug 06, 2019 at 12:09:38PM -0700, Matthew Wilcox wrote: >>> Has anyone looked at turning the interface inside-out? ie something like: >>> >>> struct mm_walk_state state = { .mm = mm, .start = start, .end = end, }; >>> >>> for_each_page_range(&state, page) { >>> ... do something with page ... >>> } >>> >>> with appropriate macrology along the lines of: >>> >>> #define for_each_page_range(state, page) \ >>> while ((page = page_range_walk_next(state))) >>> >>> Then you don't need to package anything up into structs that are shared >>> between the caller and the iterated function. >> >> I'm not an all that huge fan of super magic macro loops. But in this >> case I don't see how it could even work, as we get special callbacks >> for huge pages and holes, and people are trying to add a few more ops >> as well. > > We could have bits in the mm_walk_state which indicate what things to return > and what things to skip. We could (and probably should) also use different > iterator names if people actually want to iterate different things. eg > for_each_pte_range(&state, pte) as well as for_each_page_range(). > The iterator approach could be awkward for the likes of my generic ptdump implementation[1]. It would require an iterator which returns all levels and allows skipping levels when required (to prevent KASAN slowing things down too much). So something like: start_walk_range(&state); for_each_page_range(&state, page) { switch(page->level) { case PTE: ... case PMD: if (...) skip_pmd(&state); ... case HOLE: .... ... } } end_walk_range(&state); It seems a little fragile - e.g. we wouldn't (easily) get type checking that you are actually treating a PTE as a pte_t. The state mutators like skip_pmd() also seem a bit clumsy. Steve [1] https://lore.kernel.org/lkml/20190731154603.41797-20-steven.price@arm.com/