From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EC42EC2BBC7 for ; Tue, 14 Apr 2020 00:13:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91EA620768 for ; Tue, 14 Apr 2020 00:13:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91EA620768 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F08498E0003; Mon, 13 Apr 2020 20:13:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EB9CC8E0001; Mon, 13 Apr 2020 20:13:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF7888E0003; Mon, 13 Apr 2020 20:13:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0089.hostedemail.com [216.40.44.89]) by kanga.kvack.org (Postfix) with ESMTP id C51C38E0001 for ; Mon, 13 Apr 2020 20:13:55 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8AFB64DCB for ; Tue, 14 Apr 2020 00:13:55 +0000 (UTC) X-FDA: 76704537630.08.crib48_2232ea4282424 X-HE-Tag: crib48_2232ea4282424 X-Filterd-Recvd-Size: 3687 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 00:13:54 +0000 (UTC) IronPort-SDR: qv1Z+tl1empBq7b0SNNtXU3srx1A7OLbDWaXkeLkbU4b2qLuj36RzQxC8PNG22G46SI+vy2nfI ffxfvGhyVVzA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Apr 2020 17:13:53 -0700 IronPort-SDR: WwSP/bjwzVqCvzpfDJVQx7mHVD9DqAVfA90u9u6YJ0BE3eg8B7Aus6XqC75wdrzGtPX0vlI9oI I6IjfgU71shQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,380,1580803200"; d="scan'208";a="277078198" Received: from joy-optiplex-7040.sh.intel.com (HELO joy-OptiPlex-7040) ([10.239.13.16]) by fmsmga004.fm.intel.com with ESMTP; 13 Apr 2020 17:13:48 -0700 Date: Mon, 13 Apr 2020 20:04:10 -0400 From: Yan Zhao To: Christoph Hellwig Cc: Jens Axboe , Felipe Balbi , "Michael S. Tsirkin" , Jason Wang , intel-gvt-dev@lists.freedesktop.org, Felix Kuehling , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, io-uring@vger.kernel.org, linux-mm@kvack.org, Zhenyu Wang , intel-gfx@lists.freedesktop.org, linux-fsdevel@vger.kernel.org, Alex Deucher , Andrew Morton , virtualization@lists.linux-foundation.org, Linus Torvalds , Zhi Wang , Al Viro Subject: Re: [PATCH 2/6] i915/gvt/kvm: a NULL ->mm does not mean a thread is a kthread Message-ID: <20200414000410.GE10586@joy-OptiPlex-7040> Reply-To: Yan Zhao References: <20200404094101.672954-1-hch@lst.de> <20200404094101.672954-3-hch@lst.de> <20200407030845.GA10586@joy-OptiPlex-7040> <20200413132730.GB14455@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200413132730.GB14455@lst.de> User-Agent: Mutt/1.9.4 (2018-02-28) 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: On Mon, Apr 13, 2020 at 03:27:30PM +0200, Christoph Hellwig wrote: > On Mon, Apr 06, 2020 at 11:08:46PM -0400, Yan Zhao wrote: > > hi > > we were removing this code. see > > https://lore.kernel.org/kvm/20200313031109.7989-1-yan.y.zhao@intel.com/ > > This didn't make 5.7-rc1. > > > The implementation of vfio_dma_rw() has been in vfio next tree. > > https://github.com/awilliam/linux-vfio/commit/8d46c0cca5f4dc0538173d62cd36b1119b5105bc > > > This made 5.7-rc1, so I'll update the series to take it into account. > > T > > in vfio_dma_rw(), we still use > > bool kthread = current->mm == NULL. > > because if current->mm != NULL and current->flags & PF_KTHREAD, instead > > of calling use_mm(), we first check if (current->mm == mm) and allow copy_to_user() if it's true. > > > > Do you think it's all right? > > I can't think of another way for a kernel thread to have a mm indeed. for example, before calling to vfio_dma_rw(), a kernel thread has already called use_mm(), then its current->mm is not null, and it has flag PF_KTHREAD. in this case, we just want to allow the copy_to_user() directly if current->mm == mm, rather than call another use_mm() again. do you think it makes sense? Thanks Yan > _______________________________________________ > intel-gvt-dev mailing list > intel-gvt-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev