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 34E6FC43334 for ; Tue, 21 Jun 2022 17:09:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BFFD48E0005; Tue, 21 Jun 2022 13:09:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B86A28E0003; Tue, 21 Jun 2022 13:09:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A00AE8E0005; Tue, 21 Jun 2022 13:09:41 -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 8CC678E0003 for ; Tue, 21 Jun 2022 13:09:41 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 635C112101A for ; Tue, 21 Jun 2022 17:09:41 +0000 (UTC) X-FDA: 79602879762.28.5F79322 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 03D73140019 for ; Tue, 21 Jun 2022 17:09:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655831380; 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=5kAhXV5ceZVd9SW+rj4Nij9cH0l8kTqdMQa24MeO028=; b=MkSU6gu6Z3PhZI3jYXlTpX6fZYdRMnUsGY1jDkFiP776MUDifoszk1EsneLLPqFn0Y7xNf q0Q6WFseJpGzhbAxoNCmISAowHoBODxWEFdB/Cs2RNCs6tanQ189V38J5nhhcYLIVpFQ3p mcKpDQKWqG7sfCZC72ANbcmLkGiwvi0= Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-N1_h21JsN6iAe111Kjnhow-1; Tue, 21 Jun 2022 13:09:37 -0400 X-MC-Unique: N1_h21JsN6iAe111Kjnhow-1 Received: by mail-io1-f71.google.com with SMTP id w21-20020a5d9cd5000000b00669e6796a8aso7914578iow.7 for ; Tue, 21 Jun 2022 10:09:37 -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=5kAhXV5ceZVd9SW+rj4Nij9cH0l8kTqdMQa24MeO028=; b=y5kwLwAoZ5MvOQP9WVnXxA2GmcZnHh5yhPx5lhTIs9OupEHj7In/rFvAMRJ/26EK3d Al+9CEeip4RSSjbEqEJkVx35gX2zFZxd/XuFqsGw3Rr+TCHW0UbMDw4r3NO5gAlrrRht nv/a3XgPeZJwU6xnfhnAKCkrZne5EZSVP0SkB/4Z3zgFAyJ1jWupAvACK4lmnQYOMfQ+ 162S7F7v6XHCL+RJX0qvze1jLJoyZ+AsLIwL9P2b1b78YsfTA6aNYWsFOugWdl+/pNU1 iN3FG9jy1mLgdBsaXazLmlSYJbyVFJtK7R+Kdpi6bHafRPeqQtx/Aq3Q/4PPqvnb1so+ 7kkg== X-Gm-Message-State: AJIora+xUEG/9mfil7jyERGMUmgRFxUrg152Nak0Epk2FB1OMBNcdKLv cfeG0f2S8UK2T95Ox4dnDN4LeirOraSnAxv5mxYWOnyh74oTa98oMFb4nTD7qNgLn7DzYXIu0M+ lgCgYZbpzpks= X-Received: by 2002:a05:6638:240a:b0:332:783:156b with SMTP id z10-20020a056638240a00b003320783156bmr16359094jat.306.1655831376642; Tue, 21 Jun 2022 10:09:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sEoM/q2ZzHHdyf2r5gcqetk1jTonW7PHJFLpLSAjDLzc2r35SkR603oJ4EMetLtOp4Z+ydng== X-Received: by 2002:a05:6638:240a:b0:332:783:156b with SMTP id z10-20020a056638240a00b003320783156bmr16359088jat.306.1655831376427; Tue, 21 Jun 2022 10:09:36 -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 o33-20020a027421000000b00331a211407fsm7406362jac.93.2022.06.21.10.09.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Jun 2022 10:09:35 -0700 (PDT) Date: Tue, 21 Jun 2022 13:09:34 -0400 From: Peter Xu To: David Hildenbrand Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, "Dr . David Alan Gilbert" , Linux MM Mailing List , Sean Christopherson , Paolo Bonzini , Andrea Arcangeli , Andrew Morton Subject: Re: [PATCH RFC 1/4] mm/gup: Add FOLL_INTERRUPTIBLE Message-ID: References: <20220617014147.7299-1-peterx@redhat.com> <20220617014147.7299-2-peterx@redhat.com> <212f8b31-e470-d62c-0090-537d0d60add9@redhat.com> MIME-Version: 1.0 In-Reply-To: <212f8b31-e470-d62c-0090-537d0d60add9@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655831381; 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=5kAhXV5ceZVd9SW+rj4Nij9cH0l8kTqdMQa24MeO028=; b=V867B4kBV7WfPSaj7ufmb8hgN+w76kkWiRRciDVcWTucCA8VqjcHa3fdJ8efPIYsZfjahl fcWy/b05TkcNxG04TibOz3sHg9NveP5debWF9ObK6UZj8kGWlWKB3rioS6T976FHo3Q90r FElVKQ8D+tbWI9DNHvNRvsXH4L9ka/I= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MkSU6gu6; spf=none (imf09.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655831381; a=rsa-sha256; cv=none; b=8Uh2ORzDMMVOyy31jSP+dY6tQv0JzT/h1Fnjl05IjBHl5uOR6DKNcepgn7+voZDtYs614H NQ8VGVwXKJxDp+CpXUNHKgJ/kpfBhN716QgDkJ35UehcGOchCDappuywwNbWJ47Uk54ZQU auv33HJSXpVKqXaFwNZhTyvLL4SzZKI= X-Stat-Signature: 6fhu9hoxmwccr3na5ex9qgcbxr9tphxr X-Rspamd-Queue-Id: 03D73140019 X-Rspamd-Server: rspam11 X-Rspam-User: Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MkSU6gu6; spf=none (imf09.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1655831380-154114 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, Jun 21, 2022 at 10:23:32AM +0200, David Hildenbrand wrote: > On 17.06.22 03:41, Peter Xu wrote: > > We have had FAULT_FLAG_INTERRUPTIBLE but it was never applied to GUPs. One > > issue with it is that not all GUP paths are able to handle signal delivers > > besides SIGKILL. > > > > That's not ideal for the GUP users who are actually able to handle these > > cases, like KVM. > > > > KVM uses GUP extensively on faulting guest pages, during which we've got > > existing infrastructures to retry a page fault at a later time. Allowing > > the GUP to be interrupted by generic signals can make KVM related threads > > to be more responsive. For examples: > > > > (1) SIGUSR1: which QEMU/KVM uses to deliver an inter-process IPI, > > e.g. when the admin issues a vm_stop QMP command, SIGUSR1 can be > > generated to kick the vcpus out of kernel context immediately, > > > > (2) SIGINT: which can be used with interactive hypervisor users to stop a > > virtual machine with Ctrl-C without any delays/hangs, > > > > (3) SIGTRAP: which grants GDB capability even during page faults that are > > stuck for a long time. > > > > Normally hypervisor will be able to receive these signals properly, but not > > if we're stuck in a GUP for a long time for whatever reason. It happens > > easily with a stucked postcopy migration when e.g. a network temp failure > > happens, then some vcpu threads can hang death waiting for the pages. With > > the new FOLL_INTERRUPTIBLE, we can allow GUP users like KVM to selectively > > enable the ability to trap these signals. > > This makes sense to me. I assume relevant callers will detect "GUP > failed" but also "well, there is a signal to handle" and cleanly back > off, correct? Correct, via an -EINTR. One thing to mention is that the gup user behavior will be the same as before if the caller didn't explicilty pass in FOLL_INTERRUPTIBLE with the gup call. So after the whole series applied only kvm (and only some path of kvm, not all GUP; I only touched up the x86 slow page fault path) to handle this, but that'll be far enough to cover 99.99% use cases that I wanted to take care of. E.g., some kvm request to gup on some guest apic page may not still be able to respond to a SIGUSR1 but that's very very rare, and we can always add more users of FOLL_INTERRUPTIBLE when the code is ready to benefit from the fast respondings. Thanks, -- Peter Xu