From patchwork Fri Aug 24 19:25:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10575705 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94F20921 for ; Fri, 24 Aug 2018 19:26:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83DCB2BA85 for ; Fri, 24 Aug 2018 19:26:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77F3E2BAE7; Fri, 24 Aug 2018 19:26:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3A022BA85 for ; Fri, 24 Aug 2018 19:26:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D3366B3132; Fri, 24 Aug 2018 15:25:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 434E76B312F; Fri, 24 Aug 2018 15:25:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DF6A6B3133; Fri, 24 Aug 2018 15:25:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by kanga.kvack.org (Postfix) with ESMTP id EE96A6B312F for ; Fri, 24 Aug 2018 15:25:55 -0400 (EDT) Received: by mail-qk0-f199.google.com with SMTP id d194-v6so8459871qkb.12 for ; Fri, 24 Aug 2018 12:25:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=AAFnBEnM/0PgHx4HyJY2dSAuwG0Kwrv6FT26CubiiUk=; b=fbTLChLZKr2Jng9r4CfWWCrrOs5Zhwq7bMZfEjOAdv+fwyEY1Tu+e/cp45aV0o9S9V dZAQ22JouCM+MNRT//L2RC+586YgtPr+8P+HWq+uvgfTKRgdGv0bK3F9OEwJNW/CKsm9 +QeXp/2BnTKy19Yq4WxfLHpRHe+sa0vHO5k0F5WlF53K9jlcD1DXQt67YF7VKmOenRyA kVhnRfSjDUFoFo7I6DWGYtwPXr2evdPP97EuBp/aucDNFNao8KfdQcoOVVcU/DjIhsgp aSAid34fiiVXIzEvxNSJoqniGpIGWiVY2kJXHOylbsf3VMXcqdOf7cezIIJW4T6PdnEU Mj9g== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: APzg51C4cptPFtDs6/4LgxwQqEReWuFThlONnkkFLCk1ExVyZFIjK47c mjJzI1bLdLGfxlxpUrh+e45NXhtWk6LokEtiQzU8TcVTLd2B7g5VaZG6ont/aS1KmSHVp/J0EBP e6/Aq9lWyobQ+yxw9pU3fRNmXUBlJt0IYZSTWEkwoWV4rTa4GvwX3gULSiuaWnGH1sA== X-Received: by 2002:a37:a38b:: with SMTP id m133-v6mr3180147qke.356.1535138755754; Fri, 24 Aug 2018 12:25:55 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZp1t8wGgTGR+JveLCPGIJhzKmc+1wPEHjT+1pGbX4ZwhFQ/oWkKDsEbvAd72LXnCkaJ5LI X-Received: by 2002:a37:a38b:: with SMTP id m133-v6mr3180123qke.356.1535138755281; Fri, 24 Aug 2018 12:25:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535138755; cv=none; d=google.com; s=arc-20160816; b=T+HVLuatV20MeaCiF6vWjWZ1AWOl3+/L6jKTKWIhNdQh7PB0DyzfgJ5RB2rbtdhJEx xdGw/79K3XXbM2tYpIAE0OXue22kGA3YYqYY0FwHF2S3qYpA7wWzpdTCo0gpWN53GFjh rT6BbFAD4409cudVDZ0bDkk3ML8P3xzGRv4oX77+smWRb29LXQRGKWPLMDM1fVRFi4yv Qx/1K/azg9zS5yNsbDW8YX9zoQA46QeOw8jA4YnUwcpeGYPGRLU48iBwZHyt77JRmlYG CEJh2Oty312k2PxUsKkk1G+a3ySkX1pFO8+d9S3kUhZIGe8kVEc67roToD64sfswDAtX SCBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=AAFnBEnM/0PgHx4HyJY2dSAuwG0Kwrv6FT26CubiiUk=; b=GoPRAl9fkHOVu/77ulQPNwcLLHbsF5juuCUbd3vLAy1p2HtFgtZ9NSDmIU1viDVf0+ /eCIf7FbLKkXP8Wzzfefl2sitNR+wpoIAFj0bXicX+lPt+bMYwywqAisI3spQj/xfnPy gVqsV7zeIzKry3kWF+XJdsQH/DoQOtENTIM9+MRtKrFjA+R1jC0yXMzilhMAX6XeJ09w gm7mZK53Mc0WobNTKZbkWQsc/zJYOrIv1kQECPfsnc7N5CsC1S1c6DQHoJ4VSIqztzlB eQaELyZASNxmkM7+55nV3juzKwg+uZuoUoKqNnw/kH7jcJ6a1gJsMOX94yAeEVw4b2iZ NLLg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from mx1.redhat.com (mx3-rdu2.redhat.com. [66.187.233.73]) by mx.google.com with ESMTPS id t28-v6si2188486qta.348.2018.08.24.12.25.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Aug 2018 12:25:55 -0700 (PDT) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) client-ip=66.187.233.73; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 66.187.233.73 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EBB8E804B9F4; Fri, 24 Aug 2018 19:25:54 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-122-125.rdu2.redhat.com [10.10.122.125]) by smtp.corp.redhat.com (Postfix) with ESMTP id 81A972026D6D; Fri, 24 Aug 2018 19:25:54 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , Ralph Campbell , John Hubbard Subject: [PATCH 5/7] mm/hmm: use a structure for update callback parameters Date: Fri, 24 Aug 2018 15:25:47 -0400 Message-Id: <20180824192549.30844-6-jglisse@redhat.com> In-Reply-To: <20180824192549.30844-1-jglisse@redhat.com> References: <20180824192549.30844-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 24 Aug 2018 19:25:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Fri, 24 Aug 2018 19:25:54 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jglisse@redhat.com' RCPT:'' 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jérôme Glisse Use a structure to gather all the parameters for the update callback. This make it easier when adding new parameters by avoiding having to update all callback function signature. Signed-off-by: Jérôme Glisse Cc: Ralph Campbell Cc: John Hubbard Cc: Andrew Morton --- include/linux/hmm.h | 25 +++++++++++++++++-------- mm/hmm.c | 27 ++++++++++++++------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 1ff4bae7ada7..a7f7600b6bb0 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -274,13 +274,26 @@ static inline uint64_t hmm_pfn_from_pfn(const struct hmm_range *range, struct hmm_mirror; /* - * enum hmm_update_type - type of update + * enum hmm_update_event - type of update * @HMM_UPDATE_INVALIDATE: invalidate range (no indication as to why) */ -enum hmm_update_type { +enum hmm_update_event { HMM_UPDATE_INVALIDATE, }; +/* + * struct hmm_update - HMM update informations for callback + * + * @start: virtual start address of the range to update + * @end: virtual end address of the range to update + * @event: event triggering the update (what is happening) + */ +struct hmm_update { + unsigned long start; + unsigned long end; + enum hmm_update_event event; +}; + /* * struct hmm_mirror_ops - HMM mirror device operations callback * @@ -300,9 +313,7 @@ struct hmm_mirror_ops { /* sync_cpu_device_pagetables() - synchronize page tables * * @mirror: pointer to struct hmm_mirror - * @update_type: type of update that occurred to the CPU page table - * @start: virtual start address of the range to update - * @end: virtual end address of the range to update + * @update: update informations (see struct hmm_update) * * This callback ultimately originates from mmu_notifiers when the CPU * page table is updated. The device driver must update its page table @@ -314,9 +325,7 @@ struct hmm_mirror_ops { * synchronous call. */ void (*sync_cpu_device_pagetables)(struct hmm_mirror *mirror, - enum hmm_update_type update_type, - unsigned long start, - unsigned long end); + const struct hmm_update *update); }; /* diff --git a/mm/hmm.c b/mm/hmm.c index 659efc9aada6..debd2f734ab5 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -127,9 +127,7 @@ void hmm_mm_destroy(struct mm_struct *mm) } static void hmm_invalidate_range(struct hmm *hmm, - enum hmm_update_type action, - unsigned long start, - unsigned long end) + const struct hmm_update *update) { struct hmm_mirror *mirror; struct hmm_range *range; @@ -138,21 +136,20 @@ static void hmm_invalidate_range(struct hmm *hmm, list_for_each_entry(range, &hmm->ranges, list) { unsigned long addr, idx, npages; - if (end < range->start || start >= range->end) + if (update->end < range->start || update->start >= range->end) continue; range->valid = false; - addr = max(start, range->start); + addr = max(update->start, range->start); idx = (addr - range->start) >> PAGE_SHIFT; - npages = (min(range->end, end) - addr) >> PAGE_SHIFT; + npages = (min(range->end, update->end) - addr) >> PAGE_SHIFT; memset(&range->pfns[idx], 0, sizeof(*range->pfns) * npages); } spin_unlock(&hmm->lock); down_read(&hmm->mirrors_sem); list_for_each_entry(mirror, &hmm->mirrors, list) - mirror->ops->sync_cpu_device_pagetables(mirror, action, - start, end); + mirror->ops->sync_cpu_device_pagetables(mirror, update); up_read(&hmm->mirrors_sem); } @@ -183,10 +180,10 @@ static void hmm_release(struct mmu_notifier *mn, struct mm_struct *mm) } static int hmm_invalidate_range_start(struct mmu_notifier *mn, - struct mm_struct *mm, - unsigned long start, - unsigned long end, - bool blockable) + struct mm_struct *mm, + unsigned long start, + unsigned long end, + bool blockable) { struct hmm *hmm = mm->hmm; @@ -202,11 +199,15 @@ static void hmm_invalidate_range_end(struct mmu_notifier *mn, unsigned long start, unsigned long end) { + struct hmm_update update; struct hmm *hmm = mm->hmm; VM_BUG_ON(!hmm); - hmm_invalidate_range(mm->hmm, HMM_UPDATE_INVALIDATE, start, end); + update.start = start; + update.end = end; + update.event = HMM_UPDATE_INVALIDATE; + hmm_invalidate_range(hmm, &update); } static const struct mmu_notifier_ops hmm_mmu_notifier_ops = {