Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1815040imu; Thu, 17 Jan 2019 03:47:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN407alC41T34qzeipv7HM98ASDcxxFlmTJWc4RzSu8KW51nwf9WsIrIWASL0B+2BsosYAfj X-Received: by 2002:a17:902:722:: with SMTP id 31mr14715848pli.271.1547725667001; Thu, 17 Jan 2019 03:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547725666; cv=none; d=google.com; s=arc-20160816; b=lj7nRneEK6yOEzEYNSnxopOMoHvjkCMiqHkTn8wII+rP/Zf1f2sgSznuxGidh2gTut oIRv/yUeS0+W0Zc1B6C5cMt8t8a57EfoF30pjPPk7GLhQY/L/cBKPgAvOmCISU+/+x9b at8MIpZmhkWdrdGTrGnwMxNNbdojpbNGgLSaX9Fgsp6C6x6te25mNG0XYQrkDOew/QYO 0N08yHQBytbuNgJ0hrjN32CL7HBHjDN9+KkgGQambhVsdb4VV70HjlH8pmzPzf7MuDjd +M0zRir1K3IZvYDPHBcLLOg345eqNlCE42qGmxlRCU+lnPNPu/zGgVJz3G9PpzTq0ySk hmPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=dfsp1dXyx45JIGMw+iqNIkL28PGq42l3fxGxKYjLfd0=; b=n2OFEFbZeywxEECmogmx6Z7MGrWC2B4TdNtfCD2JbM9HZdpVO8R9XKDneCgmBj08qw fz+DukG8A2z4dialaxrfZVvV/g/WPVhgeRFQwbYPK1Ar6Cn0QSu74Ha2hYwQs6Jv/IMr cy1KHeMvsmABIpkySM0dUliLt/Cmm1bplS3dCl84x49Sz9ZhNo0FpQdttA6rURVruztZ /Ei/lk0wQoXxGU0zkDa8jFVxKin6il4LdOxXgQXby/onCvwqTQ8gptOc2rtCSSw6jAjM i1CPuExUMmFEE3sN4s81b9Z3ERN4ZIeoA7zBUfURtTPKUx6mN8iDfaOi0GQpV6CxVSgi WVBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=lQHGLopf; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g124si1309865pgc.568.2019.01.17.03.47.31; Thu, 17 Jan 2019 03:47:46 -0800 (PST) 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=@oracle.com header.s=corp-2018-07-02 header.b=lQHGLopf; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728176AbfAQKYI (ORCPT + 99 others); Thu, 17 Jan 2019 05:24:08 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:54078 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727510AbfAQKYH (ORCPT ); Thu, 17 Jan 2019 05:24:07 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0HAJ9aY133557; Thu, 17 Jan 2019 10:24:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : references : cc : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=dfsp1dXyx45JIGMw+iqNIkL28PGq42l3fxGxKYjLfd0=; b=lQHGLopfddFR0kr876kDa4yDAVF2U2oN7JuFApSeBdZGryr2+iCRpmxaFsAD/IUNz2u2 g6cc+CzwIfoeG28y6HuLH6pWMQEJjp5vXmms12bD9Mkj0tfHfEFETJPQkkXa26xF7j3j eOnhDyk6TB4qk4qOoKVqaajckMQqYpJeMTuB/bK2Z9XSy3SaKiRPAKesja8b8X8Zw3tN 10IQft5SVu1MZGUyyOVVUq8vTYn/JD15U46yhgci8MXVL2um1gMezYCM2ZWLWUi8cAf3 UG475KCec4qPc9cKejSMZ5KTmW/TtXLnvCxWzn939YFZAO912QHNrhojEfvym3fJEB+z mg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2pybjny29h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jan 2019 10:24:01 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0HAO0Qn010046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Jan 2019 10:24:01 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x0HAO0VZ030901; Thu, 17 Jan 2019 10:24:00 GMT Received: from [10.191.26.246] (/10.191.26.246) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Jan 2019 02:23:59 -0800 Subject: Re: [Xen-devel] [PATCH 1/1] xen-blkback: do not wake up shutdown_wq after xen_blkif_schedule() is stopped To: =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= References: <1547646461-29803-1-git-send-email-dongli.zhang@oracle.com> <20190116145215.igakzdkklc6f7h6k@mac> <30770f68-34e0-d707-b087-c43f0b51cd81@oracle.com> <20190117082043.7y4gl4uave5pgawf@mac> Cc: linux-block@vger.kernel.org, xen-devel@lists.xenproject.org, axboe@kernel.dk, linux-kernel@vger.kernel.org, konrad.wilk@oracle.com From: Dongli Zhang Message-ID: <00a7b217-ead4-06e2-2eaa-56c6d1920372@oracle.com> Date: Thu, 17 Jan 2019 18:23:54 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <20190117082043.7y4gl4uave5pgawf@mac> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9138 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901170076 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Roger, On 01/17/2019 04:20 PM, Roger Pau Monné wrote: > On Thu, Jan 17, 2019 at 10:10:00AM +0800, Dongli Zhang wrote: >> Hi Roger, >> >> On 2019/1/16 下午10:52, Roger Pau Monné wrote: >>> On Wed, Jan 16, 2019 at 09:47:41PM +0800, Dongli Zhang wrote: >>>> There is no need to wake up xen_blkif_schedule() as kthread_stop() is able >>>> to already wake up the kernel thread. >>>> >>>> Signed-off-by: Dongli Zhang >>>> --- >>>> drivers/block/xen-blkback/xenbus.c | 4 +--- >>>> 1 file changed, 1 insertion(+), 3 deletions(-) >>>> >>>> diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c >>>> index a4bc74e..37ac59e 100644 >>>> --- a/drivers/block/xen-blkback/xenbus.c >>>> +++ b/drivers/block/xen-blkback/xenbus.c >>>> @@ -254,10 +254,8 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif) >>>> if (!ring->active) >>>> continue; >>>> >>>> - if (ring->xenblkd) { >>>> + if (ring->xenblkd) >>>> kthread_stop(ring->xenblkd); >>>> - wake_up(&ring->shutdown_wq); >>> >>> I've now realized that shutdown_wq is basically useless, and should be >>> removed, could you please do it in this patch? >> >> I do not think shutdown_wq is useless. >> >> It is used to halt the xen_blkif_schedule() kthread when >> RING_REQUEST_PROD_OVERFLOW() returns true in __do_block_io_op(): >> >> 1121 static int >> 1122 __do_block_io_op(struct xen_blkif_ring *ring) >> ... ... >> 1134 if (RING_REQUEST_PROD_OVERFLOW(&blk_rings->common, rp)) { >> 1135 rc = blk_rings->common.rsp_prod_pvt; >> 1136 pr_warn("Frontend provided bogus ring requests (%d - %d = >> %d). Halting ring processing on dev=%04x\n", >> 1137 rp, rc, rp - rc, ring->blkif->vbd.pdevice); >> 1138 return -EACCES; >> 1139 } >> >> >> If there is bogus/invalid ring requests, __do_block_io_op() would return -EACCES >> without modifying prod/cons index. >> >> Without shutdown_wq (just simply assuming we remove the below code without >> handling -EACCES in xen_blkif_schedule()), the kernel thread would continue the >> while loop. >> >> 648 if (ret == -EACCES) >> 649 wait_event_interruptible(ring->shutdown_wq, >> 650 kthread_should_stop()); >> >> >> If xen_blkif_be_int() is triggered again (let's assume there is no optimization >> on guest part and guest would send event for every request it puts on ring >> buffer), we may come to do_block_io_op() again. >> >> >> As the prod/cons index are not modified last time the code runs into >> do_block_io_op() to process bogus request, we would hit the bogus request issue >> again. >> >> >> With shutdown_wq, the kernel kthread is blocked forever until such queue/ring is >> destroyed. If we remove shutdown_wq, we are changing the policy to handle bogus >> requests on ring buffer? > > AFAICT the only wakeup call to shutdown_wq is removed in this patch, > hence waiting on it seems useless. I would replace the > wait_event_interruptible call in xen_blkif_schedule with a break, so > that the kthread ends as soon as a bogus request is found. I think > there's no point in waiting for xen_blkif_disconnect to stop the > kthread. > > Thanks, Roger. > My fault. The shutdown_wq is useless. I think I was going to say wait_event_interruptible() is useful as it is used to halt the kthread when there is bogus request. It is fine to replace wait_event_interruptible with a break to exit immediately when there is bogus request. Thank you very much! Dongli Zhang