Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp23776pxb; Wed, 14 Apr 2021 08:34:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5KWodLtWY1WR2T9ayV7KTWVG8S0Gyvn90/MBW29dChrS6FhdX3GTV0l6CD3a25sUg64vt X-Received: by 2002:a05:6402:270c:: with SMTP id y12mr41957123edd.284.1618414498472; Wed, 14 Apr 2021 08:34:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618414498; cv=none; d=google.com; s=arc-20160816; b=UbcADRFFRKy0JIAoK35CIY2zwdYY7P+pkNMD+M6Ck6U4qGinqC1/A4qFmyHGolw/Nq VLbhlLCxRkMXARlCtysjtJfZAqV9+pu6kr3/jCGLf/X1IScA9RCW5Gq7/TDT5eymEedq +4koV8+OrxhTqHiF5XZ8jMod/b8B/bxxdskObdAFFTjphrXT+RMVTcJrC183vzEIr1dp 3hO9KabiHf5PBjPh1p67TkRq18bSnQe6RKcsiHyiQXhS9EiIlK6IGshqH/2aGM6T5NXR JGJ+fonB+fo825+NwLIQGdVRW0t03O6emU2FvxA2XwHxpsZukWGiGvnazt/fIwc5euzd iRdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=MdiSvu0mAYaO+NbL80wywdjVKgnL0Ev6Ikk9LtWkV24=; b=pgqAeQqQJ9Ml6Hnl0wIQDtzLKHBxtV+i2RnWNWQI6ShTt0ng43SGwDXI3kByRMhG8T NA78ysAbIKPvc550c8CLxoMmEylBt4JGyC+XdW1HrqMLBRFbEnCaOWWnYCG4r15SD4rJ cxmV4fZ769+GJw36oQJq1zq7rSh48Dt4Zrlin2OvIq+dWozDNabr1D0YiQIwtR1YD4Jo /ztZ6WGPpaub988USPiPtY8lKWc1fCFemwGIoJPciic700owOjh28zM2EZP7YVnYsssw eNFgosJ3T4SOyMABVuw4bFpDaOqOOGFA+B4nd+pYN1hSlAIg32KWrHsFQH3AOSZPWbuJ j2sQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g1si7494438ejw.615.2021.04.14.08.34.35; Wed, 14 Apr 2021 08:34:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350480AbhDNL2H (ORCPT + 99 others); Wed, 14 Apr 2021 07:28:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:52102 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbhDNL2G (ORCPT ); Wed, 14 Apr 2021 07:28:06 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 2713EAFE1; Wed, 14 Apr 2021 11:27:44 +0000 (UTC) Date: Wed, 14 Apr 2021 13:27:43 +0200 (CEST) From: Miroslav Benes To: xiaojun.zhao141@gmail.com cc: josef@toxicpanda.com, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: the qemu-nbd process automatically exit with the commit 43347d56c 'livepatch: send a fake signal to all blocking tasks' In-Reply-To: <20210414115548.0cdb529b@slime> Message-ID: References: <20210414115548.0cdb529b@slime> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, 14 Apr 2021, xiaojun.zhao141@gmail.com wrote: > I found the qemu-nbd process(started with qemu-nbd -t -c /dev/nbd0 > nbd.qcow2) will automatically exit when I patched for functions of > the nbd with livepatch. > > The nbd relative source: > static int nbd_start_device_ioctl(struct nbd_device *nbd, struct block_device *bdev) > { > struct nbd_config *config = nbd->config; > int ret; > > ret = nbd_start_device(nbd); > if (ret) > return ret; > > if (max_part) > bdev->bd_invalidated = 1; > mutex_unlock(&nbd->config_lock); > ret = wait_event_interruptible(config->recv_wq, > atomic_read(&config->recv_threads) == 0); > if (ret) > sock_shutdown(nbd); > flush_workqueue(nbd->recv_workq); > > mutex_lock(&nbd->config_lock); > nbd_bdev_reset(bdev); > /* user requested, ignore socket errors */ > if (test_bit(NBD_RT_DISCONNECT_REQUESTED, &config->runtime_flags)) > ret = 0; > if (test_bit(NBD_RT_TIMEDOUT, &config->runtime_flags)) > ret = -ETIMEDOUT; > return ret; > } So my understanding is that ndb spawns a number (config->recv_threads) of workqueue jobs and then waits for them to finish. It waits interruptedly. Now, any signal would make wait_event_interruptible() to return -ERESTARTSYS. Livepatch fake signal is no exception there. The error is then propagated back to the userspace. Unless a user requested a disconnection or there is timeout set. How does the userspace then reacts to it? Is _interruptible there because the userspace sends a signal in case of NBD_RT_DISCONNECT_REQUESTED set? How does the userspace handles ordinary signals? This all sounds a bit strange, but I may be missing something easily. > When the nbd waits for atomic_read(&config->recv_threads) == 0, the klp > will send a fake signal to it then the qemu-nbd process exits. And the > signal of sysfs to control this action was removed in the commit > 10b3d52790e 'livepatch: Remove signal sysfs attribute'. Are there other > ways to control this action? How? No, there is no way currently. We send a fake signal automatically. Regards Miroslav