Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp158026pxb; Thu, 21 Jan 2021 04:03:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzW0ba6GHv6QD49E8sgjs8Rs8uhxrZIJnPYli8sVFJzUUr/7wf4gGZmnmEGxbSdWOCVu+LC X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr11073770edc.207.1611230604584; Thu, 21 Jan 2021 04:03:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611230604; cv=none; d=google.com; s=arc-20160816; b=DekNNoAtdNu7jN6FmLg4oIuv9ulNaEF6aEZgwIuWMF7OUNiDmhPd4t20XrAUC2Q97v 9qOt2uP2KSr5ATY5QWkhGnayhFG2YEljjjqgv59gFOOqrYeoZGMN750W6t2+b1zcye46 6rJZyATvLfiap4DxHn2Zp7lbxjdK9yyvTdz8idcmjLgXyWRKQBfGsVP3SZsT1rekJfws I3a/REbAmVfTZ4sHXjlS94wCWD7l1dTXpAeeP3vE8DMEntoJiHGHYs/4927K7wx8lLdG h1BV+14/gqr3bWrUwLxJ+qhdumM3ne0iVACN/f4Y3nZZ4RfziuWnLHn0aMvbKeFYBbsM /ztA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=qYepdNWXQwjQLRRRVoTbPHUbyBwRVmxBVDNROTRKXH8=; b=oigusqE15JoT0aYJVOiCuB35C0LYRSdNSX87nAipTSDRAvYaDC1kiBTR4d6EiY8en9 UlOpu++o0NZ8g9porga996+jMQvD8EuHEijmF5BUsiwV9RCknIGnp/5+QrihHnvHTWNb ZRNjuOM2/SZEw/BHuWGeg7xeV133lJIL1LsxvJSJD7pBKHXavjse0g3RBVNOa8timFhD cPqGrvEQStf3zhP3AQoNDorXB+4oNQ2i3AGmOStz/QPqp5WJRJ0nDBikcezIRCIUVg9t 6bkfCagV7SWriN4DALHJ2y6wvMA3xuuwg1vF5/4CpaPtowUvyaaapFlJvMQQd6bdsgoK z1ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="toli/KAX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si1698640ejv.559.2021.01.21.04.02.52; Thu, 21 Jan 2021 04:03:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="toli/KAX"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728771AbhAUMB6 (ORCPT + 99 others); Thu, 21 Jan 2021 07:01:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:42794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728590AbhAULTb (ORCPT ); Thu, 21 Jan 2021 06:19:31 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 91534238E3; Thu, 21 Jan 2021 11:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611227930; bh=PZuL4K4MYilESgvpiWC4rYkLNV2J+t9XEez4xaSZDhQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=toli/KAXTTPqeLTr5dhCpZSbbkR/nfPoBwIhlslp/Jr2Ej1AMLBlb8/Np8uj9qh5r ckT+4oKqdLY2RKQYnAGZ0EJCvXNhDz2l0w3JVn8zB8vy+O23CVfbdO/4I3UkspLJZN fn3hYrpjVDZgEgj+mXiPzIOcWrba1k/zzwq96sV4= Date: Thu, 21 Jan 2021 12:18:47 +0100 From: Greg Kroah-Hartman To: "Song Bao Hua (Barry Song)" Cc: "Wangzhou (B)" , Zhangfei Gao , Arnd Bergmann , "linux-accelerators@lists.ozlabs.org" , "linux-kernel@vger.kernel.org" , "chensihang (A)" Subject: Re: [PATCH] uacce: Add uacce_ctrl misc device Message-ID: References: <1611220154-90232-1-git-send-email-wangzhou1@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 21, 2021 at 10:18:24AM +0000, Song Bao Hua (Barry Song) wrote: > > > > -----Original Message----- > > From: Greg Kroah-Hartman [mailto:gregkh@linuxfoundation.org] > > Sent: Thursday, January 21, 2021 10:46 PM > > To: Wangzhou (B) > > Cc: Zhangfei Gao ; Arnd Bergmann ; > > linux-accelerators@lists.ozlabs.org; linux-kernel@vger.kernel.org; > > chensihang (A) > > Subject: Re: [PATCH] uacce: Add uacce_ctrl misc device > > > > On Thu, Jan 21, 2021 at 05:09:14PM +0800, Zhou Wang wrote: > > > When IO page fault happens, DMA performance will be affected. Pin user page > > > can avoid IO page fault, this patch introduces a new char device named > > > /dev/uacce_ctrl to help to maintain pin/unpin pages. User space can do > > > pin/unpin pages by ioctls of an open file of /dev/uacce_ctrl, all pinned > > > pages under one file will be unpinned in file release process. > > > > Also, what are you really trying to do here? If you need to mess with > > memory pages, why can't the existing memory apis work properly for you? > > Please work with the linux-mm developers to resolve the issue using the > > standard apis and not creating a one-off char device node for this type > > of thing. > > Basically the purpose is implementing a pinned memory poll for userspace > DMA to achieve better performance by removing io page fault. And what could possibly go wrong with that :) > I really like this can be done in generic mm code. Unfortunately there is no > this standard API in kernel to support userspace pin. Right now, various > subsystems depend on the ioctl of /dev/ to implement the pin, for example, > v4l2, gpu, infiniband, media etc. > > I feel it is extremely hard to sell a standard mpin() API like mlock() > for this stage as mm could hardly buy this. And it will require > huge changes in kernel. Why? This is what mlock() is for, why can't you use it? > We need a way to manage what pages are pinned by process and ensure the > pages can be unpinned while the process is killed abnormally. otherwise, > memory gets leaked. Can't mlock() handle that? It works on the process that called it. > file_operations release() is a good entry for this kind of things. In > this way, we don't have to maintain the pinned page set in task_struct > and unpin them during exit(). > > If there is anything to make it better by doing this in a driver. I > would believe we could have a generic misc driver for pin like > vms_ballon.c for ballon. The driver doesn't have to bind with uacce. > > In this way, the pinned memory pool implementation in userspace doesn't > need to depend on a specific uacce driver any more. Please work with the mm developers to get them to agree with this type of thing, as well as the dma developers, both of which you didn't cc: on this patch :( Remember, you are creating a new api for Linux that goes around existing syscalls, but is in reality, a new syscall, so why not just make it a new syscall? thanks, greg k-h