Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1118549ybl; Wed, 14 Aug 2019 11:01:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdYWApLWe0xOCwpUeCt1KEidDr1Ugq535hBYfTa3xnNmXnVcKu2EotbvpY+//b8hfgDa0K X-Received: by 2002:a65:6891:: with SMTP id e17mr336680pgt.305.1565805700345; Wed, 14 Aug 2019 11:01:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565805700; cv=none; d=google.com; s=arc-20160816; b=xq3utrUH4MRxNRZ4Mm6Q5/pFP7sZ1H+ypG3hSXkNMzwhUygsy++QEJdxQatkJ6nDMH Of6m41YoZNc7mG69vYj+Z56SNyD2T6X3D9l57P9eBG31FpW25tU093tAhLbRznuci3DS U/TL1WtRw5A5V/SkLYBL2JYZdE4wrViIi0qitEWx8rvSgKxXY84ooQDsSg1J9sAsa4g6 6+88fqiqtL7bwsPdRPbgZqtOzywW0A8XZiO5+Dm7sn2igzWI22nOfXn89GWlDoSknfq4 lgDL4slgNr7z1F6xsFiZa13AcZyug/sCzubukTE5/o/hV/IWGED682huj/7TljXP/faV a4Zg== 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=dOMdAe6AqeWQZHyQVAAMCKAQHRACwZHKY6wC0SFV1+U=; b=Cu60HY687KEmfWcZrTnGte8cgwMZpacDZUj/TE2VHhHrxYao4IrNexTapsM49iUR9G or0YHYYXuHpuXMx4DRRO2QFvnkUpF/exEv0Z8sqONdxOQm3FNovaPpwW7ey+TykOoMmX YCgUvi6Wg4SR7Kr6TmhSpE4pwWYuodFlElp4Ha8J6ZiLG4Nre5kc51Kx+gT6ah87RMIc cXTRK5zlpGjnwN42GwstcFfx6XEJX0elriuuSYeY57ikakGNkH8zWg67n5GNEvPQsz6i UTy+nx3sbn0mpqHvCFIs6L/eZCcqzl2a5lq0WXa491qQpQVsaIO5PqjwT/6UA5puuUwe VHRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=txtm+14G; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9si132966pfi.170.2019.08.14.11.01.23; Wed, 14 Aug 2019 11:01:40 -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=@gmail.com header.s=20161025 header.b=txtm+14G; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbfHNSAn (ORCPT + 99 others); Wed, 14 Aug 2019 14:00:43 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44773 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726166AbfHNSAn (ORCPT ); Wed, 14 Aug 2019 14:00:43 -0400 Received: by mail-pf1-f193.google.com with SMTP id c81so5015856pfc.11 for ; Wed, 14 Aug 2019 11:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=dOMdAe6AqeWQZHyQVAAMCKAQHRACwZHKY6wC0SFV1+U=; b=txtm+14GF2FCSoDvBp13P47mYXIYr8VsHkaLQ9+qzdynxVrPmEdrI3/VF89cQ40aHO oxgSbC3sqrQqx4xtNgEWud9V7Y4Dwtgcs6TVrtMZcHWviQjqMfZK0m7rwk7t1BmWhL7L jWgqAFWfDcXmgPVogpvNZ1QoXmGGaF/uugJYIukTmXWp8cMQSuxBrfSLITM80ysXXMT3 oWiTb+hlXjbV3rib2xR5s/FAWi4i3cAD/CvYQEfnRmwJ2sSeajSsXWxylBCiLmiZ4aPT c1/PlQHMFj3pkkIDK6pLYs3vrH9UYO5JkL3zkEzOVg8YFl/aVm51r/jjD2V+EuNOMKgA PQhQ== 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=dOMdAe6AqeWQZHyQVAAMCKAQHRACwZHKY6wC0SFV1+U=; b=UVq1Wo+zav8mHsEDtFsxOzP2qEthpxxtsenDvPxY694qTF7Zg41o+ip9EYgqhqNEQ4 CC1Ks5MYHO4TlPncojYPcPyGNbln8kbtRKfcDoFiXbSfT3rBTQElVAgDQ1ZYSMGSYeye eJvrDRN0SDg+P+z/LtgXwl65/SwZf8NT5E1W4MdymTxME5Amj2pkA2P7uki8Hro+wFDX q6eag/Dw7iPcDBaCKOwhZbPPMcb/ocVlQSXaPj8hciYekqdo6sSe0T7w481MnOuU8f1L WJTX1xREvuIvauu1nBUhBjciB2gGEPZfdwBGF71JFUBV8PKWySzQ+NjrZOYBeOthT8Qj GmRQ== X-Gm-Message-State: APjAAAXwlx689DVtWj+fDk4ONNSAF9Gtlzo5NkTF0r7dZdO6rwxfx5TJ EDHjqs1lkvqF63/op1OAJFhH4Ds4 X-Received: by 2002:a17:90a:fe01:: with SMTP id ck1mr866293pjb.89.1565805642428; Wed, 14 Aug 2019 11:00:42 -0700 (PDT) Received: from bharath12345-Inspiron-5559 ([103.110.42.36]) by smtp.gmail.com with ESMTPSA id x25sm527942pfa.90.2019.08.14.11.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Aug 2019 11:00:41 -0700 (PDT) Date: Wed, 14 Aug 2019 23:30:31 +0530 From: Bharath Vedartham To: Jason Gunthorpe 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: <20190814180031.GB5121@bharath12345-Inspiron-5559> 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> <20190814173830.GC13770@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190814173830.GC13770@ziepe.ca> User-Agent: Mutt/1.5.24 (2015-08-30) 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 02:38:30PM -0300, Jason Gunthorpe wrote: > 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 That makes sense. get_atomic_user_pages_remote() should not be hard to write. AFAIKS __get_user_pages_fast is special_cased for current, we could probably just add a new parameter of the mm_struct to the page table walking code in gup.c But till then I think we can approach this by the way vhost approaches this problem by switching current to the target. Thank you Bharath