Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1098598ybl; Wed, 14 Aug 2019 10:40:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqxug4YZa7hQMKgPVWLu/cJkn4W3OJiseCKhncjZSeOefrUD8th0c3sFjVYAFBNDr87MuEev X-Received: by 2002:a17:902:2884:: with SMTP id f4mr526220plb.286.1565804450906; Wed, 14 Aug 2019 10:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565804450; cv=none; d=google.com; s=arc-20160816; b=lbJHOltn6pomL99ya6aR/fqm1/ebLq+k+Muq9tEULz1+b15py4mHbHpvUV/CFrBsaP wyt2MNO1gGAx3Y9WXC6CT7N7uEJP0GYM7p4Kv0Ig4dq0Gb0IUHXKyCZsDk/BV5IYvGiu YZlS3vnDjzESpSgpUCi2ZTZ37Adk04FgMWtt1k0qJ/KRL6PspGoBTgvA+putnzZ57aRx E/qdUvhPeujsOl0pk+uBvuCAKzHeh3P2FnFWZrDj/r7HKI4M0x0HOwC/z8Ha6YWS7ANL +1tRi/T4u60KAoNUfmS4A4MKxepVLGinnO2NynadIPHvVbnKtHZYEd8KmdRx5iRmsX/5 eG9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=4BL5XZQz+p5d6tRSI8UgGndGd0i26QwDHoau6MxYYLA=; b=VnC+u+4oLMjjsnn2+pC9DGMuIZlocLjfHqlxaNh5mxSW7FlQyIn4f7Rb5/PoBOrkJu xliePkRvcEFbx2YwZQgu97J2JyHT+7Ut6AtdPXq+/dbEXFQm1DglL5d2r104pvpVg2h5 5SRrJOOiBbaevLRyrxnWPhYq1wbomUVtBwQXmS/tKqx0ap5Jpje39H+0LpZq94MHfbkF D2Mlp2Z+2tHfyg+EBlXCGeQ2gjpVxg3XqDoich7V5Hx6suuR1if2bD+4MBxz4OsK3GL4 ohGHXAXH7E7UUgeNl5WLkfJ0OWXGOy3A4GDm8tzK4gwpXmaJJ97AEK2nTZyHVlgYDJzP yGiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="GZ5y/O3f"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z9si299412plo.66.2019.08.14.10.40.34; Wed, 14 Aug 2019 10:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b="GZ5y/O3f"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728712AbfHNRid (ORCPT + 99 others); Wed, 14 Aug 2019 13:38:33 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:42550 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727558AbfHNRic (ORCPT ); Wed, 14 Aug 2019 13:38:32 -0400 Received: by mail-qt1-f196.google.com with SMTP id t12so22439377qtp.9 for ; Wed, 14 Aug 2019 10:38:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4BL5XZQz+p5d6tRSI8UgGndGd0i26QwDHoau6MxYYLA=; b=GZ5y/O3fyBNnstbyvOADsRpKWOCP6tLzpWK55C2O1o3SaTumF2M8WN5IquV0vharRJ Vj6F0ER/zA4UHC1gLoJgqgJmo1pUufEieBTrdTqoGIBq2N4DUumbW/cMJbrl1VVNByad 4aZw5rj4SSAm/2VgxPx3ehp5ieE8vIwRpTpcljvn4XtLfC/IJjeZRnOJxcC9IAXjC348 u6NmUmhnUOWJ+9pf7Cg19TgIe9oMd4mmBt4OgnbpwVPRlHasESVQXh8DgORDFL7e9dIY DQQ1R3SBs+BxU2oSOxNE84A+2nDuDnbsk5f6AxEuLomLooVFQuDKqC8zTybwExG7DYQv Ovww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=4BL5XZQz+p5d6tRSI8UgGndGd0i26QwDHoau6MxYYLA=; b=mfFin5hI6tbbMiDxzNudkCNyESaaYTDFmqZUDLD6EuK2SUJYPXvWD/o4jTlhgdiTKC wpQpPEcyrkJh4p1xj6LaqZky1CzcVfrDCcfFvwMk+PRfnVbUOyn/cnkRJs2Tvg1ulzM/ SzE/74rgoi3yk+XKaN39B47+80nGKsEkHxuMDpewcaP+GAjkwNEKJySEtjVJ5WVY2b0w qJwYn1LxRIFnjN5vt4xvimP/0It7TU9UTrB1oePjghe1uxRt2U7pXrOG8ghBe2RLA/tS BghhU21wmpXU+/pHbQ4kZ/s1ycTqfVwi5bojbQWCxMOBpVxEttgl9u4cZRXcAo2VFOFE qT5Q== X-Gm-Message-State: APjAAAVLKr08XfWqZL0L774hm8v8+KUO/DQyFW4VRQ4RF4bWtycCRH13 6KKdIDHD14KGQD8xHTwksf03Zg== X-Received: by 2002:aed:2fe6:: with SMTP id m93mr512005qtd.114.1565804311976; Wed, 14 Aug 2019 10:38:31 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id j61sm150258qte.47.2019.08.14.10.38.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Aug 2019 10:38:31 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hxxEE-0001nN-UV; Wed, 14 Aug 2019 14:38:30 -0300 Date: Wed, 14 Aug 2019 14:38:30 -0300 From: Jason Gunthorpe To: Bharath Vedartham Cc: Dimitri Sivanich , jhubbard@nvidia.com, gregkh@linuxfoundation.org, arnd@arndb.de, ira.weiny@intel.com, jglisse@redhat.com, william.kucharski@oracle.com, hch@lst.de, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kernel-mentees@lists.linuxfoundation.org Subject: Re: [Linux-kernel-mentees][PATCH v5 1/1] sgi-gru: Remove *pte_lookup functions, Convert to get_user_page*() Message-ID: <20190814173830.GC13770@ziepe.ca> References: <1565379497-29266-1-git-send-email-linux.bhar@gmail.com> <1565379497-29266-2-git-send-email-linux.bhar@gmail.com> <20190813145029.GA32451@hpe.com> <20190813172301.GA10228@bharath12345-Inspiron-5559> <20190813181938.GA4196@hpe.com> <20190814173034.GA5121@bharath12345-Inspiron-5559> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190814173034.GA5121@bharath12345-Inspiron-5559> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 14, 2019 at 11:00:34PM +0530, Bharath Vedartham wrote: > On Tue, Aug 13, 2019 at 01:19:38PM -0500, Dimitri Sivanich wrote: > > On Tue, Aug 13, 2019 at 10:53:01PM +0530, Bharath Vedartham wrote: > > > On Tue, Aug 13, 2019 at 09:50:29AM -0500, Dimitri Sivanich wrote: > > > > Bharath, > > > > > > > > I do not believe that __get_user_pages_fast will work for the atomic case, as > > > > there is no guarantee that the 'current->mm' will be the correct one for the > > > > process in question, as the process might have moved away from the cpu that is > > > > handling interrupts for it's context. > > > So what your saying is, there may be cases where current->mm != gts->ts_mm > > > right? __get_user_pages_fast and get_user_pages do assume current->mm. > > > > Correct, in the case of atomic context. > > > > > > > > These changes were inspired a bit from kvm. In kvm/kvm_main.c, > > > hva_to_pfn_fast uses __get_user_pages_fast. THe comment above the > > > function states it runs in atomic context. > > > > > > Just curious, get_user_pages also uses current->mm. Do you think that is > > > also an issue? > > > > Not in non-atomic context. Notice that it is currently done that way. > > > > > > > > Do you feel using get_user_pages_remote would be a better idea? We can > > > specify the mm_struct in get_user_pages_remote? > > > > From that standpoint maybe, but is it safe in interrupt context? > Hmm.. The gup maintainers seemed fine with the code.. > > Now this is only an issue if gru_vtop can be executed in an interrupt > context. > > get_user_pages_remote is not valid in an interrupt context(if CONFIG_MMU > is set). If we follow the function, in __get_user_pages, cond_resched() > is called which definitly confirms that we can't run this function in an > interrupt context. > > I think we might need some advice from the gup maintainers here. > Note that the comment on the function __get_user_pages_fast states that > __get_user_pages_fast is IRQ-safe. vhost is doing some approach where they switch current to the target then call __get_user_pages_fast in an IRQ context, that might be a reasonable pattern If this is a regular occurance we should probably add a get_atomic_user_pages_remote() to make the pattern clear. Jason