Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3302652img; Mon, 25 Mar 2019 07:41:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPjo3s3+sAU9I0buwN014OiYL++7AKGjwzshfZPMyZXuw7/ITX2iuSVarBMqbHNw1SOATG X-Received: by 2002:a62:1157:: with SMTP id z84mr2225287pfi.159.1553524889703; Mon, 25 Mar 2019 07:41:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553524889; cv=none; d=google.com; s=arc-20160816; b=GksaYMVF4hXBorVMiJKuwQ9l9uMPdHNTCq8qK3Z+R4jDGcUW+AEFxmZUKsnLEG7Ghi CHAf20dHoZ11UxlMiNp6oU/M2YJfvnOx5SfS5/usHEWVEHolDoB/gLSfjEX7iFObqRDH lMz1BhmhvEJAz/uGPS3x67uR4fD8IKZBmIJ5QZh1uEttuQpCqycx+PmHg8sRo3LimrT4 UFcI89BMdKOF0or0lX6dnpqVVzQh9cgLnpXEJqqs/VeA+Jgr+Q35K5xpGYZ/aVWZbzgG 0ZrllpHCu0dfBlxtWEFMAYJmida8wbMQZXTBhnzvw5f7qJPcOWNItG6aaN/iK6TQU3bo rr7Q== 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=2sp6d/tamBRD55gqEYdNuviJE1ZEteUB7U7gWf01poQ=; b=b3BUtyLwDZUtjszd2kCehPBKRVvEEqnLwmbHMDDA+PVZBzC+h3c87eZ/ixc+4DpsMY XyhDQNlnN+dUos8WabfDTDz1qWtlas6gkCy4lyeZg5iMLJ10+658h+0+6x0i/03cm15F 7Thgy9+mplskwYTah3FrbbKKkWNr13TXYvycHWDQHC1kORe4lvw0V7jyceSKz4zURqVi P5uipHTsIixhbSksDRmjT3iI3n424rRUvPPCgP7Xf+YiMQ0xl6e7R3Kp993KJRTIhhGW ICi4colTjJNbEXBWFeoDS5N+19LTsIjxqgBFU/zgfkhCO6IU2perljXaDTwaU4a/y9Yt 2UFg== 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 n1si14770749pld.251.2019.03.25.07.41.14; Mon, 25 Mar 2019 07:41:29 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbfCYOk1 (ORCPT + 99 others); Mon, 25 Mar 2019 10:40:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57312 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729178AbfCYOkU (ORCPT ); Mon, 25 Mar 2019 10:40:20 -0400 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 429C530832EA; Mon, 25 Mar 2019 14:40:20 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.20.6.236]) by smtp.corp.redhat.com (Postfix) with ESMTP id 920CD100164A; Mon, 25 Mar 2019 14:40:19 +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 , John Hubbard , Dan Williams Subject: [PATCH v2 07/11] mm/hmm: add default fault flags to avoid the need to pre-fill pfns arrays. Date: Mon, 25 Mar 2019 10:40:07 -0400 Message-Id: <20190325144011.10560-8-jglisse@redhat.com> In-Reply-To: <20190325144011.10560-1-jglisse@redhat.com> References: <20190325144011.10560-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.44]); Mon, 25 Mar 2019 14:40:20 +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 Reviewed-by: Ralph Campbell Cc: Andrew Morton Cc: John Hubbard Cc: Dan Williams --- 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 79671036cb5f..13bc2c72f791 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 fa9498eeb9b6..4fe88a196d17 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -415,6 +415,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