Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3660666pxb; Mon, 24 Jan 2022 14:43:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvbH8zIhQzvU2GPw1CODFrMFVRx7PjPXArhaVvBqPRxxZU8JhxWNsmcWIJ9nmHL2fFHoa2 X-Received: by 2002:a17:90b:3143:: with SMTP id ip3mr446971pjb.230.1643064182899; Mon, 24 Jan 2022 14:43:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643064182; cv=none; d=google.com; s=arc-20160816; b=XqruUVJU6i+rHNyaN8AgiPZO+4RPRNej3A2A3bEg1euUm1clyVS+2TIZSZJa09D5ZT 7bfS/5aHd/JpsCVpRk1QZKaIpb7eYSLZ/LlZyggQbItqbX6dJid1Z0uLdZ06I/ZJru29 31LFN15Hn75tCLDy9V/h1JBKLr/tJxASFFOEeGiMWtUs0iJDSFj+/kA2lyQUZNUWazWB GbF1GckcgBWb5wXbd6oQ64/+V54dM8wcG2C3g+5PnSmPOAqXYtG9aAAEi2f0n7Eh8zL4 vK+yD2vpmVEjIrzqVXJfCD9Kf6Zt09INphEvAU0AZCaVeAZDYxEWh68jFKq4b6nEeg0Z q7jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w2OZgDbZoBws7qYa/EgyLHgK+lRvFSKP20k02IJEngU=; b=VIOTbN6D/ij6cYAFOOfslkf9mnpAWSDbNs8QKqeAKQ1IottzCm02vwsgtOHUqXaevu 6AMKiL94KjXknKADRIufLf35g/94REJhnpjmhOxpGt7UGwQM90riL6yXYEfKs4KMu7ok Q5B2QUrHBxK4dgXA0KZaZrNLVTYJ68UOcShi4d+Ccdp+K/wbny3lO2dYsgc+g4asiatl mZxX1b1YwV5kZXtYd+HuJn3yeDQ5BZxNd6v6SXiwGd8g2wsCoq24qUEHqPQJGx2e84JS QPmjugDYlnrUS04x47RDrWyLHC7V4s14dYUUNf0aVudBFeclcQ+a4bZvqjWa0PmM+thd z13w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hWou1DMI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j2si497615pjt.122.2022.01.24.14.42.51; Mon, 24 Jan 2022 14:43:02 -0800 (PST) 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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hWou1DMI; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1836716AbiAXWkj (ORCPT + 99 others); Mon, 24 Jan 2022 17:40:39 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:59604 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1457406AbiAXVlf (ORCPT ); Mon, 24 Jan 2022 16:41:35 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7A7A4612E5; Mon, 24 Jan 2022 21:41:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6263CC340E4; Mon, 24 Jan 2022 21:41:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060493; bh=Vh3Qu6x8QyubpqhLHnKB1MKyOTmTneYTQS/GwGEp5z8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hWou1DMIPjOnETDaY6ZQWJlkQBtHEyWWRYgx4Coj4v6efrhsX2L8ZpXqqGYgRSNII gjnmGNR39qzQ5soFfVuoR0OQQwV/ZzyTnTo+UyMOhs1tgrZwRQJNe40P5dilRy5/bJ oCiQL5tZj+Gl7mFYW3XAoj4YaKxd0qO5K60r+6Qk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Gu , "David S. Miller" Subject: [PATCH 5.16 0966/1039] net/smc: Fix hung_task when removing SMC-R devices Date: Mon, 24 Jan 2022 19:45:55 +0100 Message-Id: <20220124184157.760163768@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wen Gu commit 56d99e81ecbc997a5f984684d0eeb583992b2072 upstream. A hung_task is observed when removing SMC-R devices. Suppose that a link group has two active links(lnk_A, lnk_B) associated with two different SMC-R devices(dev_A, dev_B). When dev_A is removed, the link group will be removed from smc_lgr_list and added into lgr_linkdown_list. lnk_A will be cleared and smcibdev(A)->lnk_cnt will reach to zero. However, when dev_B is removed then, the link group can't be found in smc_lgr_list and lnk_B won't be cleared, making smcibdev->lnk_cnt never reaches zero, which causes a hung_task. This patch fixes this issue by restoring the implementation of smc_smcr_terminate_all() to what it was before commit 349d43127dac ("net/smc: fix kernel panic caused by race of smc_sock"). The original implementation also satisfies the intention that make sure QP destroy earlier than CQ destroy because we will always wait for smcibdev->lnk_cnt reaches zero, which guarantees QP has been destroyed. Fixes: 349d43127dac ("net/smc: fix kernel panic caused by race of smc_sock") Signed-off-by: Wen Gu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/smc/smc_core.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) --- a/net/smc/smc_core.c +++ b/net/smc/smc_core.c @@ -1459,16 +1459,11 @@ void smc_smcd_terminate_all(struct smcd_ /* Called when an SMCR device is removed or the smc module is unloaded. * If smcibdev is given, all SMCR link groups using this device are terminated. * If smcibdev is NULL, all SMCR link groups are terminated. - * - * We must wait here for QPs been destroyed before we destroy the CQs, - * or we won't received any CQEs and cdc_pend_tx_wr cannot reach 0 thus - * smc_sock cannot be released. */ void smc_smcr_terminate_all(struct smc_ib_device *smcibdev) { struct smc_link_group *lgr, *lg; LIST_HEAD(lgr_free_list); - LIST_HEAD(lgr_linkdown_list); int i; spin_lock_bh(&smc_lgr_list.lock); @@ -1480,7 +1475,7 @@ void smc_smcr_terminate_all(struct smc_i list_for_each_entry_safe(lgr, lg, &smc_lgr_list.list, list) { for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) { if (lgr->lnk[i].smcibdev == smcibdev) - list_move_tail(&lgr->list, &lgr_linkdown_list); + smcr_link_down_cond_sched(&lgr->lnk[i]); } } } @@ -1492,16 +1487,6 @@ void smc_smcr_terminate_all(struct smc_i __smc_lgr_terminate(lgr, false); } - list_for_each_entry_safe(lgr, lg, &lgr_linkdown_list, list) { - for (i = 0; i < SMC_LINKS_PER_LGR_MAX; i++) { - if (lgr->lnk[i].smcibdev == smcibdev) { - mutex_lock(&lgr->llc_conf_mutex); - smcr_link_down_cond(&lgr->lnk[i]); - mutex_unlock(&lgr->llc_conf_mutex); - } - } - } - if (smcibdev) { if (atomic_read(&smcibdev->lnk_cnt)) wait_event(smcibdev->lnks_deleted,