Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4874323imu; Tue, 29 Jan 2019 08:57:28 -0800 (PST) X-Google-Smtp-Source: ALg8bN6YV0UtmlNhP+204PaEEwTgLgwhYZF/HAwhtNMws+i6/jpaUFOMkmCOTuZ1ODu8fomRSEUY X-Received: by 2002:a63:4c5:: with SMTP id 188mr24572130pge.391.1548781048413; Tue, 29 Jan 2019 08:57:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548781048; cv=none; d=google.com; s=arc-20160816; b=G1vGwCunBkrc6fl8hgSH0F+DpM0O1aNDp2+elM1jHuo8gPUNtDMftn9up/NO4KrCWC BoZeA5tc5w664UhlpIj+o4gxyphC6Ee6610BzQN9KH9/JSzeiJoy/KU+mAYINxjwYUwf MikIQ3BVVivs/7CWUojZFAPCsNtaIH3HYqzTnBfgNUWbAG198OixRcvaY1C+1/0/EaEz xYFull75q9yEZoTuVwmmDqIeR9dHxan/+qz2CKRK4mPS0NC+YzAzu+cS5H8IiH55Neih S8lndEwnT+QwiHSI/3azh/5rUKOYtczNfz02KY7zO2Dcf4bZrew6y3wX2KUjE8kNBeH2 PicA== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PI7GUp8ZvA3zxJ+GcKn6vnogCxLfh9GqOCOpMvvb278=; b=EpIQhoU4myrSyki3nscupQCWCMxzz+QCmGqIAjfPHpxvpfEnB2pOxANVc4ZbffO1Uy IYoLpwIpVqKKyogPYLRHMLkn2MYLZ8ufA16eYgKZDvGf3EIc1xk89tsdRlkzdeB3TNiz Iw450C5sveoi6DMlwl4UwFw5aNT9kzwZcvcdlvfI6UmPKbD9KBidTVN5ORisAhM5uZpP 6NCsp1ZjCZG2sTu4LM36qbdUeGfFH8rS/dBzUcCa9RpXgCo3Rp05ce8o99ESPIyB2CLk idqbuA+o3XjUVrH6SZEZRFNX6D3POQ7OAaMbEpCsiVSxR2Ph1ajvc9Veg9HdzmcdiNF0 bR4g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si37840927pln.78.2019.01.29.08.57.13; Tue, 29 Jan 2019 08:57:28 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728935AbfA2QzR (ORCPT + 99 others); Tue, 29 Jan 2019 11:55:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31941 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728696AbfA2Qyr (ORCPT ); Tue, 29 Jan 2019 11:54:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C76D680F79; Tue, 29 Jan 2019 16:54:46 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-122-2.rdu2.redhat.com [10.10.122.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1EC4102BCEB; Tue, 29 Jan 2019 16:54:45 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Andrew Morton , Ralph Campbell , John Hubbard Subject: [PATCH 06/10] mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays. Date: Tue, 29 Jan 2019 11:54:24 -0500 Message-Id: <20190129165428.3931-7-jglisse@redhat.com> In-Reply-To: <20190129165428.3931-1-jglisse@redhat.com> References: <20190129165428.3931-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 29 Jan 2019 16:54:46 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jérôme Glisse The HMM mirror API can be use in two fashions. The first one where the HMM user coalesce multiple page faults into one request and set flags per pfns for of those faults. The second one where the HMM user want to pre-fault a range with specific flags. For the latter one it is a waste to have the user pre-fill the pfn arrays with a default flags value. This patch adds a default flags value allowing user to set them for a range without having to pre-fill the pfn array. Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Ralph Campbell Cc: John Hubbard --- include/linux/hmm.h | 7 +++++++ mm/hmm.c | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 93dc88edc293..4263f8fb32e5 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -165,6 +165,8 @@ enum hmm_pfn_value_e { * @pfns: array of pfns (big enough for the range) * @flags: pfn flags to match device driver page table * @values: pfn value for some special case (none, special, error, ...) + * @default_flags: default flags for the range (write, read, ...) + * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT) * @valid: pfns array did not change since it has been fill by an HMM function */ @@ -177,6 +179,8 @@ struct hmm_range { uint64_t *pfns; const uint64_t *flags; const uint64_t *values; + uint64_t default_flags; + uint64_t pfn_flags_mask; uint8_t pfn_shift; bool valid; }; @@ -521,6 +525,9 @@ static inline int hmm_vma_fault(struct hmm_range *range, bool block) { long ret; + range->default_flags = 0; + range->pfn_flags_mask = -1UL; + ret = hmm_range_register(range, range->vma->vm_mm, range->start, range->end); if (ret) diff --git a/mm/hmm.c b/mm/hmm.c index 860ebe5d4b07..0a4ff31e9d7a 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -423,6 +423,18 @@ static inline void hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk, if (!hmm_vma_walk->fault) return; + /* + * So we not only consider the individual per page request we also + * consider the default flags requested for the range. The API can + * be use in 2 fashions. The first one where the HMM user coalesce + * multiple page fault into one request and set flags per pfns for + * of those faults. The second one where the HMM user want to pre- + * fault a range with specific flags. For the latter one it is a + * waste to have the user pre-fill the pfn arrays with a default + * flags value. + */ + pfns = (pfns & range->pfn_flags_mask) | range->default_flags; + /* We aren't ask to do anything ... */ if (!(pfns & range->flags[HMM_PFN_VALID])) return; -- 2.17.2