Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3306464rwa; Tue, 23 Aug 2022 02:25:43 -0700 (PDT) X-Google-Smtp-Source: AA6agR6MqriAn9SGUF18jClqNdM6kX80DQ4eLBh+v75FsG4D/h+xUWEhQwnHR2H4SxmLxN9zfPic X-Received: by 2002:a17:90b:3684:b0:1fa:f48e:abd0 with SMTP id mj4-20020a17090b368400b001faf48eabd0mr2400972pjb.180.1661246743693; Tue, 23 Aug 2022 02:25:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661246743; cv=none; d=google.com; s=arc-20160816; b=ggkRWxgg6UFzQ9DVWhkvFkZHhopCudo+N3JSuQo5bAaXk67ZDQLnO6W0M9LPZyxLR5 IFHWs9ZZ45n61RzUa/NWxP6LUdbFh/uHQeyLnsv5SFY3ywjN+UW4SmJakqE8EAXzwfi0 6653hcS50boNXZbB5TPkQLX4UFsWxXFASuzCt8TiYIfbx8IVrzN6fsluF83oyMPBJfzK /kgmZCl2P5exIfaNHrQZ8jLAcveXqSWziwe5mis/5QEmdXebqPOVLBNrqVRDI3cdYjX/ TBhcNRm3iHp5fbuYUx1Z8hkkVGVHNcctTbV90xkapxohEY+gbG6vWquYrP1iT0/s8LlM eb5Q== 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=WRFio8ysoyay/Q9SZ2T6BbJRST9CHVYXOHk/vXFKCSQ=; b=JX3pQAFrKds8FXdxN0EES46s0tyqYFGT/Io7R4vhp8T9Omw1O/hSOxPTMdVZqfHpMH u0/QYySLEeR7hnhgtkE5y+ouGmVSdEX8fxbc1cwXtjkz7OXtXVAzlE+YQwGcfto0fS+e cRGiUtbUCw8slCKIlpy/eh8tUd3S7ULCypBuDcmOSJPMmz33HcnR8ltAKfz/iBp1Ajg1 4wxWbwrxkW9XPp3w1jbBi1nbKHHXK48aQO3FTZcQRP6ZI88vnNdX0jeUWX2rNBYtR9pM DIZnnwJvAqT35fKi0OwGGufBHtfqbaB6rRsAchdzJ6iDAxIiRKtMxnXHv2nniEX4ChdY Phyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bBz1aGM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b13-20020a056a00114d00b0052fac3954e9si15005282pfm.227.2022.08.23.02.25.32; Tue, 23 Aug 2022 02:25:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bBz1aGM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1346593AbiHWJYa (ORCPT + 99 others); Tue, 23 Aug 2022 05:24:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350672AbiHWJWE (ORCPT ); Tue, 23 Aug 2022 05:22:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87B378E0CA; Tue, 23 Aug 2022 01:35:02 -0700 (PDT) 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 B6E066132D; Tue, 23 Aug 2022 08:33:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1F52C433C1; Tue, 23 Aug 2022 08:33:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243614; bh=7D0OrVKNjV5W28hSKVEGbz9KYV6kvLGpEuCpVGt/P4M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bBz1aGMQzxQzQ/0edetC0KZoEVLGdUgnEDluDf+mq5ay8C8fQUEp1JEZ39RN5QXL 82AZum4swVk5TJZ4EA1hydEL2VHVf6CK3wlKo5AHCiPp3srZk77gUs4AXJmV6EufjW ouwuQJwbeyifiZ59fLjfvqR3UHUSy/qWUaMN1lnI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bob Pearson , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.19 303/365] RDMA/rxe: Limit the number of calls to each tasklet Date: Tue, 23 Aug 2022 10:03:24 +0200 Message-Id: <20220823080130.862991649@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bob Pearson [ Upstream commit eff6d998ca297cb0b2e53b032a56cf8e04dd8b17 ] Limit the maximum number of calls to each tasklet from rxe_do_task() before yielding the cpu. When the limit is reached reschedule the tasklet and exit the calling loop. This patch prevents one tasklet from consuming 100% of a cpu core and causing a deadlock or soft lockup. Link: https://lore.kernel.org/r/20220630190425.2251-9-rpearsonhpe@gmail.com Signed-off-by: Bob Pearson Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_param.h | 6 ++++++ drivers/infiniband/sw/rxe/rxe_task.c | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h index 568a7cbd13d4..86c7a8bf3cbb 100644 --- a/drivers/infiniband/sw/rxe/rxe_param.h +++ b/drivers/infiniband/sw/rxe/rxe_param.h @@ -105,6 +105,12 @@ enum rxe_device_param { RXE_INFLIGHT_SKBS_PER_QP_HIGH = 64, RXE_INFLIGHT_SKBS_PER_QP_LOW = 16, + /* Max number of interations of each tasklet + * before yielding the cpu to let other + * work make progress + */ + RXE_MAX_ITERATIONS = 1024, + /* Delay before calling arbiter timer */ RXE_NSEC_ARB_TIMER_DELAY = 200, diff --git a/drivers/infiniband/sw/rxe/rxe_task.c b/drivers/infiniband/sw/rxe/rxe_task.c index 0c4db5bb17d7..2248cf33d776 100644 --- a/drivers/infiniband/sw/rxe/rxe_task.c +++ b/drivers/infiniband/sw/rxe/rxe_task.c @@ -8,7 +8,7 @@ #include #include -#include "rxe_task.h" +#include "rxe.h" int __rxe_do_task(struct rxe_task *task) @@ -33,6 +33,7 @@ void rxe_do_task(struct tasklet_struct *t) int cont; int ret; struct rxe_task *task = from_tasklet(task, t, tasklet); + unsigned int iterations = RXE_MAX_ITERATIONS; spin_lock_bh(&task->state_lock); switch (task->state) { @@ -61,13 +62,20 @@ void rxe_do_task(struct tasklet_struct *t) spin_lock_bh(&task->state_lock); switch (task->state) { case TASK_STATE_BUSY: - if (ret) + if (ret) { task->state = TASK_STATE_START; - else + } else if (iterations--) { cont = 1; + } else { + /* reschedule the tasklet and exit + * the loop to give up the cpu + */ + tasklet_schedule(&task->tasklet); + task->state = TASK_STATE_START; + } break; - /* soneone tried to run the task since the last time we called + /* someone tried to run the task since the last time we called * func, so we will call one more time regardless of the * return value */ -- 2.35.1