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 09131C25B07 for ; Wed, 10 Aug 2022 19:38:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4E9058E0001; Wed, 10 Aug 2022 15:38:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 498AB6B0072; Wed, 10 Aug 2022 15:38:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3604B8E0001; Wed, 10 Aug 2022 15:38:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 24D8D6B0071 for ; Wed, 10 Aug 2022 15:38:41 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F01FF161507 for ; Wed, 10 Aug 2022 19:38:40 +0000 (UTC) X-FDA: 79784695200.12.0E4F788 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf25.hostedemail.com (Postfix) with ESMTP id 749E9A0062 for ; Wed, 10 Aug 2022 19:38:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660160320; 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=qLEsjHSARBGbFLDoXqq+JW70Tie/allHI9QzL0wkk40=; b=X0SybXjh9H/xYLkH+aGXhdWYwedJhNfSfG0PkAiKNDg9rjxZvauruusC3Tm12loN7+I58u +55QhlVJwRVZhmVk9AApSMkf0B1YiLskLpPUH7e3INBoAk5NH4srAGp+dIHIFHjBaXEd67 daYr8IljSC5w10TazyoDCSA8hknPMWs= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-6ptFFj9SMyOCZ0DMiTPCqg-1; Wed, 10 Aug 2022 15:38:39 -0400 X-MC-Unique: 6ptFFj9SMyOCZ0DMiTPCqg-1 Received: by mail-io1-f70.google.com with SMTP id c5-20020a5ea805000000b00684468c5005so7756849ioa.15 for ; Wed, 10 Aug 2022 12:38:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc; bh=qLEsjHSARBGbFLDoXqq+JW70Tie/allHI9QzL0wkk40=; b=wKRy8vY/h2HRtnDlGK+RtXmxLlzLaeUrcWUv0XkypzhNm9G0q8woTU+MnTXepcuGps donP3+gBEIc1IS3iUnRRFwk2iW0Fxds1t7+VG9RXDCokXU7z08k3Ldxx+73L6v+N01WJ nf89lEUfDfRsadolDfnZrbB1oq2NMdxOjk/lRD1qL4H+fzaGynmxN2iV0fpH6HKlm32d rqU7M+ilfG1aASmX98KWF+W0A0bsNxIc48BKrdC70aVdp8XV9mSZmk3bGiv0NsIulx/v 91wHKXoWThCeA/5hKpDiC93k6H9SYzH4i4u4jWktI4OlpRM3G2kiqjKLMI7/s5Fh40Hk PSeg== X-Gm-Message-State: ACgBeo1THW0qqEKrk5X5qtHrHS5R4dPL7kXigsuzmAOlok4kmQTa7iCs q/1TY03JAL5DPfAgpWqyHBJxcw9jNrCcMXcl7nAjBT1UXC0siRISuetN1UB7dZnbn5wK9AJD+lA AJTp1BiULomY= X-Received: by 2002:a05:6638:328e:b0:33f:c7e8:7bc5 with SMTP id f14-20020a056638328e00b0033fc7e87bc5mr13100944jav.48.1660160318475; Wed, 10 Aug 2022 12:38:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR6vtEo0DS2o1w+N3uEfFxGn2l0a2rD+/lrgID6TOcI3dfRSX4cLxjbixKKH8HJHCpnm+BVG4A== X-Received: by 2002:a05:6638:328e:b0:33f:c7e8:7bc5 with SMTP id f14-20020a056638328e00b0033fc7e87bc5mr13100939jav.48.1660160318303; Wed, 10 Aug 2022 12:38:38 -0700 (PDT) Received: from xz-m1.local (bras-base-aurron9127w-grc-35-70-27-3-10.dsl.bell.ca. [70.27.3.10]) by smtp.gmail.com with ESMTPSA id c37-20020a029628000000b003429303cb32sm7858183jai.54.2022.08.10.12.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Aug 2022 12:38:37 -0700 (PDT) Date: Wed, 10 Aug 2022 15:38:35 -0400 From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: David Hildenbrand , "Dr . David Alan Gilbert" , John Hubbard , Sean Christopherson , Linux MM Mailing List , Andrew Morton , Paolo Bonzini , Andrea Arcangeli Subject: Re: [PATCH v2 0/3] kvm/mm: Allow GUP to respond to non fatal signals Message-ID: References: <20220721000318.93522-1-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: <20220721000318.93522-1-peterx@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1660160320; a=rsa-sha256; cv=none; b=Ro3/nOBY70/ZQNYs4mpKTrl9hTTrFTNXvF0C3xMqe7HYdR3BL6ACd72hMS310Y64cjCTGE VgWtzYKJf9xGL6mky8uCdQ6y97JbBEih4j+45hGVOzisY0weXc1apz2Fq2RR5mYxr+U2OC 0nPuclgWTHu2jgFePFb+BdwK2MaegGU= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X0SybXjh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1660160320; 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=qLEsjHSARBGbFLDoXqq+JW70Tie/allHI9QzL0wkk40=; b=VayOJm8lqzmu2aqqkJHGtfmU2FmiuURbmYuz9HLUzJSfFLCtYx72vuGcpf/6QpNXGr0xbf HQOAVhjZA6tqY3GOKpmp0+fgDtU/icdaQcS2NZkQLK4IFUGjykockyY0HghsP2lSeEcGG9 RttGcms+kFS7domt51dcmLVezp/aMS4= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 749E9A0062 Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=X0SybXjh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf25.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Stat-Signature: rjujacf56rejaz78d1r8s99geaxwt5w9 X-Rspam-User: X-HE-Tag: 1660160320-921536 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: Any further comments? Thanks, On Wed, Jul 20, 2022 at 08:03:15PM -0400, Peter Xu wrote: > v2: > - Added r-b > - Rewrite the comment in faultin_page() for FOLL_INTERRUPTIBLE [John] > - Dropped the controversial patch to introduce a flag for > __gfn_to_pfn_memslot(), instead used a boolean for now [Sean] > - Rename s/is_sigpending_pfn/KVM_PFN_ERR_SIGPENDING/ [Sean] > - Change comment in kvm_faultin_pfn() mentioning fatal signals [Sean] > > rfc: https://lore.kernel.org/kvm/20220617014147.7299-1-peterx@redhat.com > v1: https://lore.kernel.org/kvm/20220622213656.81546-1-peterx@redhat.com > > One issue was reported that libvirt won't be able to stop the virtual > machine using QMP command "stop" during a paused postcopy migration [1]. > > It won't work because "stop the VM" operation requires the hypervisor to > kick all the vcpu threads out using SIG_IPI in QEMU (which is translated to > a SIGUSR1). However since during a paused postcopy, the vcpu threads are > hang death at handle_userfault() so there're simply not responding to the > kicks. Further, the "stop" command will further hang the QMP channel. > > The mm has facility to process generic signal (FAULT_FLAG_INTERRUPTIBLE), > however it's only used in the PF handlers only, not in GUP. Unluckily, KVM > is a heavy GUP user on guest page faults. It means we won't be able to > interrupt a long page fault for KVM fetching guest pages with what we have > right now. > > I think it's reasonable for GUP to only listen to fatal signals, as most of > the GUP users are not really ready to handle such case. But actually KVM > is not such an user, and KVM actually has rich infrastructure to handle > even generic signals, and properly deliver the signal to the userspace. > Then the page fault can be retried in the next KVM_RUN. > > This patchset added FOLL_INTERRUPTIBLE to enable FAULT_FLAG_INTERRUPTIBLE, > and let KVM be the first one to use it. KVM and mm/gup can always be able > to respond to fatal signals, but not non-fatal ones until this patchset. > > One thing to mention is that this is not allowing all KVM paths to be able > to respond to non fatal signals, but only on x86 slow page faults. In the > future when more code is ready for handling signal interruptions, we can > explore possibility to have more gup callers using FOLL_INTERRUPTIBLE. > > Tests > ===== > > I created a postcopy environment, pause the migration by shutting down the > network to emulate a network failure (so the handle_userfault() will stuck > for a long time), then I tried three things: > > (1) Sending QMP command "stop" to QEMU monitor, > (2) Hitting Ctrl-C from QEMU cmdline, > (3) GDB attach to the dest QEMU process. > > Before this patchset, all three use case hang. After the patchset, all > work just like when there's not network failure at all. > > Please have a look, thanks. > > [1] https://gitlab.com/qemu-project/qemu/-/issues/1052 -- Peter Xu