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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEEBAC433EF for ; Sat, 25 Jun 2022 01:23:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EED8D6B00EE; Fri, 24 Jun 2022 21:23:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E751A8E0284; Fri, 24 Jun 2022 21:23:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D16248E0283; Fri, 24 Jun 2022 21:23:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id BEF676B00EE for ; Fri, 24 Jun 2022 21:23:12 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 91998207C2 for ; Sat, 25 Jun 2022 01:23:12 +0000 (UTC) X-FDA: 79615009824.05.32AEADA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 1096C40026 for ; Sat, 25 Jun 2022 01:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1656120191; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=7XLzZJXOdWaEWC8BB0Bij+Fr78R+fiLBcMspKDhyed8=; b=FolPKYZb/693Kpf66xPNF5oLCdQkOcNTC2qj8gFkhXXg3BITtkWzs11wjwnhhZ2x/30jS4 Q94nGWUpcC85JDjkALakobHkqyVLYVUnop0/unTNaTLjK5FOxUPBnwydMvx98OUl+7hAHX Tn91n7V+kUiEaIcPHBmcJfgWvK7Y0Q8= Received: from mail-il1-f197.google.com (mail-il1-f197.google.com [209.85.166.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-rrDSoSnYP_KsYs-aX8RpLA-1; Fri, 24 Jun 2022 21:23:10 -0400 X-MC-Unique: rrDSoSnYP_KsYs-aX8RpLA-1 Received: by mail-il1-f197.google.com with SMTP id k8-20020a056e02156800b002d91998aef7so2590348ilu.0 for ; Fri, 24 Jun 2022 18:23:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=7XLzZJXOdWaEWC8BB0Bij+Fr78R+fiLBcMspKDhyed8=; b=rML16LoXn9EPLbYq84at92XKW0PfwhK7q0DwLzvulXN0SY49jwGHehQMBCxIWgwOrp L9XYyMWXX+GjYf7ZCnqZYn7JMop6RFjiSm/sBgj4goJkjDnoE39biMdA3JZkBFo73Log CRo6SwaggwQnQPeDwyJ+PKC1mLxhHeB7yvqQzJ5s9lNk/j6Lv74i5HzmkWMqF6Bl8Kb2 EOi3QHm/P7Me1Kg9naFDKzL028giAKEWEPoNX3fLKhU/V0bnatxOl2FrBRv3OiKauygL 248ZQPgncBrLGWd85MDpu736lWwWFfGTkx0AnlP+p/OyZDr/X6i8fa8d9LSp1bQ6PNqb jw6Q== X-Gm-Message-State: AJIora83ffn8xNh8SU7fcMOWMCfr2dkeXO0c9wCnRGUTm9krXX6TwPE6 Nfu6+QVD2UlEk9N+Z3UXeRbPngCl2AG7ukvF8rQu359S3YbNLlGjI5IsDcSU3aUUQzqh7fRYNEC s8/fDrT0Feig= X-Received: by 2002:a5d:9291:0:b0:669:d90b:24e0 with SMTP id s17-20020a5d9291000000b00669d90b24e0mr911542iom.53.1656120189523; Fri, 24 Jun 2022 18:23:09 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vU+hqUMZ39OLtBJ83hd5BrE2EQXNCbPmdU+o5BGQ4i9ivzq9fjRpN79r5OZj+RHPH35LRgzA== X-Received: by 2002:a5d:9291:0:b0:669:d90b:24e0 with SMTP id s17-20020a5d9291000000b00669d90b24e0mr911528iom.53.1656120189246; Fri, 24 Jun 2022 18:23:09 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id t16-20020a92dc10000000b002d94906dacfsm1739700iln.67.2022.06.24.18.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Jun 2022 18:23:07 -0700 (PDT) Date: Fri, 24 Jun 2022 21:23:04 -0400 From: Peter Xu To: Jason Gunthorpe Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Paolo Bonzini , Andrew Morton , David Hildenbrand , "Dr . David Alan Gilbert" , Andrea Arcangeli , Linux MM Mailing List , Sean Christopherson Subject: Re: [PATCH 1/4] mm/gup: Add FOLL_INTERRUPTIBLE Message-ID: References: <20220622213656.81546-1-peterx@redhat.com> <20220622213656.81546-2-peterx@redhat.com> <20220625003554.GJ23621@ziepe.ca> MIME-Version: 1.0 In-Reply-To: <20220625003554.GJ23621@ziepe.ca> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FolPKYZb; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656120192; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7XLzZJXOdWaEWC8BB0Bij+Fr78R+fiLBcMspKDhyed8=; b=Gf0yYcUfy33JiK8LYK4y6OriKaofmn0wLO7g6DoxnDiIPsmCHq+uNaqOyZNUltQ3CEZJwV jWvKq7OXEJ4QNj0tdsYW6YUnnRrD5JQuQj0ZMm10ugTPdB1t/764bozTienf9TdaRbEXTX 9F8JvlQPfBK4oRX/hfDNj0PfiJ5oeV8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656120192; a=rsa-sha256; cv=none; b=Xi6h+hEiQrrD2cdSvTJXniQsxorgum1B8/WumSzAyPf8BCr7R8Fk14HCqV3Uq0BJdNp09T Dpx7USMKezs4EiXSnhIrVY2yy4KmOR8EbRctUG/AAubR+9HHsgyY6RAahUosCn1T9yDLD8 epq+6kIbIRfVjJJDuBtJXpmOQPqGJ2Q= X-Stat-Signature: 3s5j4t93k9byrbax1gjk89cx1hn8a5sd X-Rspamd-Queue-Id: 1096C40026 X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FolPKYZb; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf11.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam12 X-HE-Tag: 1656120191-583921 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: Hi, Jason, On Fri, Jun 24, 2022 at 09:35:54PM -0300, Jason Gunthorpe wrote: > Can you talk abit about what is required to use this new interface > correctly? > > Lots of GUP callers are in simple system call contexts (like ioctl), > can/should they set this flag and if so what else do they need to do? Thanks for taking a look. IMHO the major thing required is the caller can handle the case when GUP returned (1) less page than expected, and (2) -EINTR returns. For the -EINTR case, IIUC ideally in an ioctl context we should better deliver it back to user app this -EINTR (while do cleanups gracefully), rather than returning anything else (e.g. converting it to -EFAULT or something else). But note that FAULT_FLAG_INTERRUPTIBLE is only used in an userfaultfd context (aka, userfaultfd_get_blocking_state()). For example, if we hang at lock_page() (if not go into whether hanging at lock_page makes sense or not at all.. it really sounds like a bug) and we receive a non-fatal signal, we won't be able to be scheduled for that since lock_page() uses TASK_UNINTERRUPTIBLE always. I think it's a separate problem on whether we should extend the usage of FAULT_FLAG_INTERRUPTIBLE to things like lock_page() (and probably not..), and currently it does solve a major issue regarding postcopy hanging on pages for hypervisor use case. Hopefully that still justifies this plumber work to enable the interruptible cap to GUP layer. If to go back to the original question with a shorter answer: if the ioctl context that GUP upon a page that will never be with a uffd context, then it's probably not gonna help at all.. at least not before we use FAULT_FLAG_INTERRUPTIBLE outside uffd page fault handling. Thanks, -- Peter Xu