From patchwork Mon Dec 3 23:35:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jerome Glisse X-Patchwork-Id: 10710909 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 D5D3614E2 for ; Mon, 3 Dec 2018 23:36:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C421929267 for ; Mon, 3 Dec 2018 23:36:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5BB32B222; Mon, 3 Dec 2018 23:36:23 +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 13C4329267 for ; Mon, 3 Dec 2018 23:36:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 56FAD6B6BB5; Mon, 3 Dec 2018 18:36:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4AB406B6BB6; Mon, 3 Dec 2018 18:36:21 -0500 (EST) 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 2A8796B6BB7; Mon, 3 Dec 2018 18:36:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by kanga.kvack.org (Postfix) with ESMTP id EFBCA6B6BB5 for ; Mon, 3 Dec 2018 18:36:20 -0500 (EST) Received: by mail-qt1-f200.google.com with SMTP id w18so15030463qts.8 for ; Mon, 03 Dec 2018 15:36:20 -0800 (PST) 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=DA+2SFd81eCmFA42hYfl77NXN7UFbB59TjS6UlfUsD8=; b=P8xRXLz+0G2ovcT2Gqm0MK7mJdh6mQpdmhkk8W6nIAl7eSYQBMDgEJ2VMxCasP9Fnx 5Femjknv0lpWz8YNmVV0t5c+VLfgcwIbslzpbEYaGvMgyBrqXRs2M1t12pU2YL1axTRL kjF3E5abE4zMS/rUznlHr5WH/h2xy50/i6Opzsc+KbWScrWLrX+EIIs4QqTgsz3bgWKx vLkz06n8LCaGo8G/ZRBG5/UAEmTlIS0i+J31KT9fjEuxJWqrOy2SMyFVDgWkoh2y+/M6 ezHnaEG3IFK8BVppsjS1NAvVAXRrfjk8Y4bMtieMvDvDkNsL2QMhmquxR4SDu2aZadDD X0MQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=jglisse@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Gm-Message-State: AA+aEWaV1Ya/B+p2Q6JgC+LOT8z0e4RcJ1zH9qOgfSeyNoeQPQVIiuuL fTkWPEniTVAlS1M1hfKDDqrpdo+xbbFBwvPMZrxEWHhH9AVoeGWVjW+1cK0S7YgnXWM4PCrUrd6 crDsIhQwE4VpNcm6AEDgsnLzO5/VQmsRcgFuI4PUDAn75TeVHS1fabMj87b4Xr5gBCQ== X-Received: by 2002:a0c:8164:: with SMTP id 91mr17723735qvc.100.1543880180737; Mon, 03 Dec 2018 15:36:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/XBk+IGgmIXXP7e02z6lxVZcmuoALiAzGuUso6S85FkrKNl+aH8nR0kP1OVDFaAt8yaAdXx X-Received: by 2002:a0c:8164:: with SMTP id 91mr17723705qvc.100.1543880180187; Mon, 03 Dec 2018 15:36:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543880180; cv=none; d=google.com; s=arc-20160816; b=EL46GtyKY/loFzSfI2HUXyqDFF3xDEaIm0Xllp5TnBgn0QLdD6KcrM3z5rzs6D9Ijk FJm4wiVpG6itnTMZwb5lnJNEmQND47yWKawV0bsHve/ZqXMgjPNI3GDJZAfVUihZEILe YsJ0XbqPn1ceF3gpmsCZYQ4sIydgtgvQZ1Rnpjn0jBqlQd+bnpZg5c55DPrsVcVwXf1k zqBV8Vqa0ysyIArcmkXwHXPJJwszXhAjrvtk8IJLjli+aVNmmx5xh28NL+jbOKK1JGEH Ky2NwdjorBG0OB34O/tmZUX1tf1UdENEGw6bXgcNOfcjogrHMj6KW+z1n/hr+4iBY6b2 Beew== 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; bh=DA+2SFd81eCmFA42hYfl77NXN7UFbB59TjS6UlfUsD8=; b=e9Yf1pdVcKPPGDUVjBfcfj9EBzHzQzfYKYKVJOLpnI4DitU1EkQwDVUzqwceJmnjuv 8e5OOcoPis+ja/zBI8C5ZIe+32U40yf9JttBkNr4yTUi/242+5qIEmdLKLyvvj/O68ug VP52UKOp7WWuWRnd0ts9GB1BsbM/2hhJyKkL74p0xX3JQ2mu8t3FXcaGLgs7in+2y83i gQ5ZX2dztWiYjwTncosIHRfHUjrqXZ7mT18fZy0UMH4F7S2p6EmsNrbEPs4mnQYxB11c wKIzHzKUfyffdi+nnk0fBIgRAtAJW/MO5g9Wm/SfZykdNl7349UzkfxZ2j18AJqU0fHN qQ5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 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 (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id k18si4490752qtb.401.2018.12.03.15.36.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Dec 2018 15:36:20 -0800 (PST) Received-SPF: pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jglisse@redhat.com designates 209.132.183.28 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-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 05B5D87629; Mon, 3 Dec 2018 23:36:19 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-120-188.rdu2.redhat.com [10.10.120.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3704600C1; Mon, 3 Dec 2018 23:36:15 +0000 (UTC) From: jglisse@redhat.com To: linux-mm@kvack.org Cc: Andrew Morton , linux-kernel@vger.kernel.org, =?utf-8?b?SsOpcsO0bWUgR2xpc3Nl?= , "Rafael J . Wysocki" , Ross Zwisler , Dan Williams , Dave Hansen , Haggai Eran , Balbir Singh , "Aneesh Kumar K . V" , Benjamin Herrenschmidt , Felix Kuehling , Philip Yang , =?utf-8?q?Christian_K=C3=B6nig?= , Paul Blinzer , Logan Gunthorpe , John Hubbard , Ralph Campbell , Michal Hocko , Jonathan Cameron , Mark Hairgrove , Vivek Kini , Mel Gorman , Dave Airlie , Ben Skeggs , Andrea Arcangeli Subject: [RFC PATCH 11/14] mm/hbind: add bind command to heterogeneous memory policy Date: Mon, 3 Dec 2018 18:35:06 -0500 Message-Id: <20181203233509.20671-12-jglisse@redhat.com> In-Reply-To: <20181203233509.20671-1-jglisse@redhat.com> References: <20181203233509.20671-1-jglisse@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 03 Dec 2018 23:36:19 +0000 (UTC) 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 This patch add bind command to hbind() ioctl, this allow to bind a range of virtual address to given list of target memory. New memory allocated in the range will try to use memory from the target memory list. Note that this patch does not modify existing page fault path and thus does not activate new heterogeneous policy. Updating the CPU page fault code path or device page fault code path (HMM) will be done in separate patches. Here we only introduce helpers and infrastructure that will be use by page fault code path. Signed-off-by: Jérôme Glisse Cc: Rafael J. Wysocki Cc: Ross Zwisler Cc: Dan Williams Cc: Dave Hansen Cc: Haggai Eran Cc: Balbir Singh Cc: Aneesh Kumar K.V Cc: Benjamin Herrenschmidt Cc: Felix Kuehling Cc: Philip Yang Cc: Christian König Cc: Paul Blinzer Cc: Logan Gunthorpe Cc: John Hubbard Cc: Ralph Campbell Cc: Michal Hocko Cc: Jonathan Cameron Cc: Mark Hairgrove Cc: Vivek Kini Cc: Mel Gorman Cc: Dave Airlie Cc: Ben Skeggs Cc: Andrea Arcangeli --- include/uapi/linux/hbind.h | 10 ++++++++++ mm/hms.c | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/include/uapi/linux/hbind.h b/include/uapi/linux/hbind.h index cc4687587f5a..7bb876954e3f 100644 --- a/include/uapi/linux/hbind.h +++ b/include/uapi/linux/hbind.h @@ -47,6 +47,16 @@ struct hbind_params { */ #define HBIND_CMD_DEFAULT 0 +/* + * HBIND_CMD_BIND strict policy ie new allocations will comes from one of the + * listed targets until they run of memory. Other targets can be use if the + * none of the listed targets can be accessed by the initiator that did fault. + * + * Additional dwords: + * NONE (DWORDS MUST BE 0 !) + */ +#define HBIND_CMD_BIND 1 + #define HBIND_IOCTL _IOWR('H', 0x00, struct hbind_params) diff --git a/mm/hms.c b/mm/hms.c index be2c4e526f25..6be6f4acdd49 100644 --- a/mm/hms.c +++ b/mm/hms.c @@ -338,6 +338,36 @@ static struct hms_policy *hms_policy_get(struct mm_struct *mm) } +static int hbind_bind(struct mm_struct *mm, struct hbind_params *params, + const uint32_t *targets, uint32_t *atoms) +{ + struct hms_policy_range *prange; + struct hms_policy *hpolicy; + int ret; + + hpolicy = hms_policy_get(mm); + if (hpolicy == NULL) + return -ENOMEM; + + prange = hms_policy_range_new(targets, params->start, params->end, + params->ntargets); + if (prange == NULL) + return -ENOMEM; + + down_write(&hpolicy->sem); + ret = hbind_default_locked(hpolicy, params); + if (ret) + goto out; + + interval_tree_insert(&prange->node, &hpolicy->ranges); + +out: + up_write(&hpolicy->sem); + + return ret; +} + + static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg) { uint32_t *targets, *_dtargets = NULL, _ftargets[HBIND_FIX_ARRAY]; @@ -418,6 +448,16 @@ static long hbind_ioctl(struct file *file, unsigned cmd, unsigned long arg) if (ret) goto out_mm; break; + case HBIND_CMD_BIND: + if (ndwords != 1) { + ret = -EINVAL; + goto out_mm; + } + ret = hbind_bind(current->mm, ¶ms, + targets, atoms); + if (ret) + goto out_mm; + break; default: ret = -EINVAL; goto out_mm;