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=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 0E912C2BB85 for ; Tue, 14 Apr 2020 07:13:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6A642074D for ; Tue, 14 Apr 2020 07:13:33 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6A642074D 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 1C07E8E0003; Tue, 14 Apr 2020 03:13:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1715E8E0001; Tue, 14 Apr 2020 03:13:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 087C18E0003; Tue, 14 Apr 2020 03:13:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0234.hostedemail.com [216.40.44.234]) by kanga.kvack.org (Postfix) with ESMTP id E2E308E0001 for ; Tue, 14 Apr 2020 03:13:32 -0400 (EDT) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9FBF8181AEF1F for ; Tue, 14 Apr 2020 07:13:32 +0000 (UTC) X-FDA: 76705595064.15.women13_3bfa9a0bb5c16 X-HE-Tag: women13_3bfa9a0bb5c16 X-Filterd-Recvd-Size: 3268 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 14 Apr 2020 07:13:31 +0000 (UTC) IronPort-SDR: NXMgZ3UcqOu1qUyQ1qQh9ybY9OQyw8UwdH+nmSlVLNwJ3w8yvx5bSxiga5eTb9x0V3PSsYusF1 Be1+xc9YyuLQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Apr 2020 00:13:27 -0700 IronPort-SDR: 3mzTZiupNXsl0k5QcLc9AHNCJBc5G9UIIEYO8qCIUclLUzsoEbBJJHUqxdgJkxiNvCr7gq5Idq YjsPeTwaKt8g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.72,381,1580803200"; d="scan'208";a="426968243" Received: from joy-optiplex-7040.sh.intel.com (HELO joy-OptiPlex-7040) ([10.239.13.16]) by orsmga005.jf.intel.com with ESMTP; 14 Apr 2020 00:13:22 -0700 Date: Tue, 14 Apr 2020 03:03:44 -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: <20200414070344.GF10586@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> <20200414000410.GE10586@joy-OptiPlex-7040> <20200414070013.GA23680@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200414070013.GA23680@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 Tue, Apr 14, 2020 at 09:00:13AM +0200, Christoph Hellwig wrote: > On Mon, Apr 13, 2020 at 08:04:10PM -0400, Yan Zhao wrote: > > > 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? > > I mean no other way than using use_mm. That being said nesting > potentional use_mm callers sounds like a rather bad idea, and we > should avoid that. yes, agree. I was explaining why we just use "current->mm == NULL" (not "current->flag & PF_KTHREAD") as a criteria to call use_mm() in vfio_dma_rw(), which you might ask us when you take that part into your series. :)