Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp6980282ybn; Mon, 30 Sep 2019 06:54:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyshr3jUdy0aMdWpR5nw3TesdY7CUwwJ9jkv4VxqsDRI/ud7YIbRcWowQ26upzNepY6efOt X-Received: by 2002:a17:906:52d8:: with SMTP id w24mr18906821ejn.6.1569851685163; Mon, 30 Sep 2019 06:54:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569851685; cv=none; d=google.com; s=arc-20160816; b=LyacR+wWvONhnUHECAZBXwDYtGKtja0ZPy1RooF7hgxiy+dMAskS9ELYS5BkYEoh+Y CpqwEqkMz1Yr9HUE9RGcV1KLzZzYUC85vFUZbgsk3UoPKK7YxTkLhy9PLXPrxVVeQREP /JOIhqzCa5gNHoef0GcE5Vv9fVYI2+c6xzwI6P9Cre3+UNS5FaU1LrIG6b2zXAybKZMT njY1pMLiWroLiNqAV88IsUoUhyFCkh5Gy3por+C/YqXItxkta/QKma7FDLrfwHdszZgW PKqCHupoKO80iXTihlDMvI7hHi4ZC+X0GT9xwSURKff4NdSC8zxBYmBTpTE/bNpHKoGO OAmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=KJecfdV4cU2EkR1odbrtXYLFF3/KCfbmiXi5v/OdwmM=; b=uG3/jchGO1OewU+K+sIVnjUhYAFOQ5HVDvHzBxeRowSfh797pwtZcmNn+6/GXoF5S/ rc/1isxCSnkDGKTpeGd1d68SniVVKDNj9XrVEhPK3LKBwA07eWrWhjp1rmJGB+SBxZbK 0PR8dDhDR/ld8444u7PNTRizO29UPAm9P1MZH0vInFB/vV5KfcImbTsItPC5NUXbffdq +dmanq9+3sVmvRKc/XtpSrr2uB6ScvETe2dfqPg3hTR+0IZLBOl3Jf9js69XSjRMvJOJ QYIT7Uh0kQGsC4Yp26Yz7rcdd0uYJQn1toVYyXdU2EgyLmgotqhdgevlrLCDzghrr9xk pUkQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si7538938edc.291.2019.09.30.06.54.20; Mon, 30 Sep 2019 06:54:45 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731442AbfI3Nvc (ORCPT + 99 others); Mon, 30 Sep 2019 09:51:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40806 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731129AbfI3Nvb (ORCPT ); Mon, 30 Sep 2019 09:51:31 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 033B3C049E36 for ; Mon, 30 Sep 2019 13:51:31 +0000 (UTC) Received: by mail-wm1-f70.google.com with SMTP id k67so3955474wmf.3 for ; Mon, 30 Sep 2019 06:51:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=KJecfdV4cU2EkR1odbrtXYLFF3/KCfbmiXi5v/OdwmM=; b=DqUUcLYRxc4Usq+pBb1VIuE3MAmyMvEvibYQkVGF2OpudnTFaRxOXYEQfIsfio2QTs VDIh/XKekHvGDBcZLFtdBFwc1bRvtiolHblO/YRGkw+t1Cwu6fAhVKvXGasB1VehU/bo CzJ4W7vS3rxyYuIyBBX+AXeA6t0nLflIuCRf1ODnqvBMzLhuRh0Qjt/izCu2GHcznUhL qkRMC78ZxnH6ny/67rB9aoTDKYOOqRpYdEbQ2MQ2VeaadsVIZZKZgs3A6wnnb2f31kyR Q2ydwzLByAazlpW46kJW5+zvTJMzFF6MRZ28nahkMTNM4f5Gm0u9asdZavGeKwNvpSBS vThg== X-Gm-Message-State: APjAAAXOzzngbX4LugP/uBq7CUtwvOJSvRJxc4mzUYhge/G5xk3Lqy0U Rzqp4kVr1haygA2YYFJMU/2BM96w0GK49GnNigHwzC8daEdURFwsvwnjaJGVFMYla+OyGwUSuMi kuviz1btV7uzNzS2rx9kc8SpA X-Received: by 2002:a05:600c:238a:: with SMTP id m10mr18590254wma.51.1569851489005; Mon, 30 Sep 2019 06:51:29 -0700 (PDT) X-Received: by 2002:a05:600c:238a:: with SMTP id m10mr18590238wma.51.1569851488775; Mon, 30 Sep 2019 06:51:28 -0700 (PDT) Received: from steredhat (host174-200-dynamic.52-79-r.retail.telecomitalia.it. [79.52.200.174]) by smtp.gmail.com with ESMTPSA id h63sm26377926wmf.15.2019.09.30.06.51.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 06:51:28 -0700 (PDT) Date: Mon, 30 Sep 2019 15:51:25 +0200 From: Stefano Garzarella To: Dexuan Cui Cc: "davem@davemloft.net" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , "sashal@kernel.org" , "stefanha@redhat.com" , "gregkh@linuxfoundation.org" , "arnd@arndb.de" , "deepa.kernel@gmail.com" , "ytht.net@gmail.com" , "tglx@linutronix.de" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-hyperv@vger.kernel.org" , "kvm@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , Michael Kelley , "jhansen@vmware.com" Subject: Re: [PATCH net v2] vsock: Fix a lockdep warning in __vsock_release() Message-ID: <20190930135125.prztj336splp74wq@steredhat> References: <1569460241-57800-1-git-send-email-decui@microsoft.com> <20190926074749.sltehhkcgfduu7n2@steredhat.homenet.telecomitalia.it> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 27, 2019 at 05:37:20AM +0000, Dexuan Cui wrote: > > From: linux-hyperv-owner@vger.kernel.org > > On Behalf Of Stefano Garzarella > > Sent: Thursday, September 26, 2019 12:48 AM > > > > Hi Dexuan, > > > > On Thu, Sep 26, 2019 at 01:11:27AM +0000, Dexuan Cui wrote: > > > ... > > > NOTE: I only tested the code on Hyper-V. I can not test the code for > > > virtio socket, as I don't have a KVM host. :-( Sorry. > > > > > > @Stefan, @Stefano: please review & test the patch for virtio socket, > > > and let me know if the patch breaks anything. Thanks! > > > > Comment below, I'll test it ASAP! > > Stefano, Thank you! > > BTW, this is how I tested the patch: > 1. write a socket server program in the guest. The program calls listen() > and then calls sleep(10000 seconds). Note: accept() is not called. > > 2. create some connections to the server program in the guest. > > 3. kill the server program by Ctrl+C, and "dmesg" will show the scary > call-trace, if the kernel is built with > CONFIG_LOCKDEP=y > CONFIG_LOCKDEP_SUPPORT=y > > 4. Apply the patch, do the same test and we should no longer see the call-trace. > Hi Dexuan, I tested on virtio socket and it works as expected! With your patch applied I don't have issues and call-trace. Without the patch I have a very similar call-trace (as expected): ============================================ WARNING: possible recursive locking detected 5.3.0-vsock #17 Not tainted -------------------------------------------- python3/872 is trying to acquire lock: ffff88802b650110 (sk_lock-AF_VSOCK){+.+.}, at: virtio_transport_release+0x34/0x330 [vmw_vsock_virtio_transport_common] but task is already holding lock: ffff88803597ce10 (sk_lock-AF_VSOCK){+.+.}, at: __vsock_release+0x3f/0x130 [vsock] other info that might help us debug this: Possible unsafe locking scenario: CPU0 ---- lock(sk_lock-AF_VSOCK); lock(sk_lock-AF_VSOCK); *** DEADLOCK *** May be due to missing lock nesting notation 2 locks held by python3/872: #0: ffff88802c957180 (&sb->s_type->i_mutex_key#8){+.+.}, at: __sock_release+0x2d/0xb0 #1: ffff88803597ce10 (sk_lock-AF_VSOCK){+.+.}, at: __vsock_release+0x3f/0x130 [vsock] stack backtrace: CPU: 0 PID: 872 Comm: python3 Not tainted 5.3.0-vsock #17 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.12.0-2.fc30 04/01/2014 Call Trace: dump_stack+0x85/0xc0 __lock_acquire.cold+0xad/0x22b lock_acquire+0xc4/0x1a0 ? virtio_transport_release+0x34/0x330 [vmw_vsock_virtio_transport_common] lock_sock_nested+0x5d/0x80 ? virtio_transport_release+0x34/0x330 [vmw_vsock_virtio_transport_common] virtio_transport_release+0x34/0x330 [vmw_vsock_virtio_transport_common] ? mark_held_locks+0x49/0x70 ? _raw_spin_unlock_irqrestore+0x44/0x60 __vsock_release+0x2d/0x130 [vsock] __vsock_release+0xb9/0x130 [vsock] vsock_release+0x12/0x30 [vsock] __sock_release+0x3d/0xb0 sock_close+0x14/0x20 __fput+0xc1/0x250 task_work_run+0x93/0xb0 exit_to_usermode_loop+0xd3/0xe0 syscall_return_slowpath+0x205/0x310 entry_SYSCALL_64_after_hwframe+0x49/0xbe Feel free to add: Tested-by: Stefano Garzarella