Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp21668447rwd; Thu, 29 Jun 2023 20:42:53 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7RTZBpkFPXYo9c1sp33cEepxGSfuNPDvUrg1Gqrp4ZlAdODTLH5I5kiU1VrkJzyB1BThLY X-Received: by 2002:a05:6a20:42a5:b0:12a:f4d2:3e25 with SMTP id o37-20020a056a2042a500b0012af4d23e25mr2104006pzj.29.1688096573131; Thu, 29 Jun 2023 20:42:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688096573; cv=none; d=google.com; s=arc-20160816; b=JbhztXQUkaErRB3yibmctsdrKPN/Hf9haCqtpZmAQ5uhZT0A6WH1WK0tTYcpplaykN NgEVVfvcHrgSaAegaxGxoZXy6d66zJp8qpUqKpIvoNxGCrBERz5BsLxnwDRWTNZEAEQu 1ztjiqlyqJb3eeIpUARUiUSEq01M7PGenHbJiJ5cs7D8L2VBH7qYBWBAn3ewW9ecSrX/ U54ioWeyn/7hP8zqVomaPAPeSXV6nOPEfc9MQd8CzMDSKZqabJkB3l4hBSidZjD1rzo6 cYmStWjzothtyOG7C9kCR9+JHtfIZ4KJErRznSE4xldbBkQpbqC/LElJJPmGglw4/q6L G3iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=OwJdxtfFrP5LDWYvOjXG/8S5IIrimErpt5RB/JNheSE=; fh=kcIAtqREV3nNlxaOQVhPDrVxTFVQlUJj+URF5IomjP0=; b=LkMKZdGAuQuKldM4Q3H0BNWiabk3UZA7MOUjqqb7m6esRKF7yYELMSZDMCLlMsJ4jF aevUBj0PwUtNSv3CHcINCukXH2T3T5Do44PWpx6goZd7EB21gUuOHk8WBV4GUQ7hHPQH H/iKuuB/gpjGYTIPg7PJannG219tHa0Wlnt1A2anCZLEtha946e9rbmIzQJoxhspkbqV xcVO+9QdcJCjeczHOmNljxzNVXMD5ZhJ1yfQTXY2v0CkaBptMl8oWjvb7Pb6jf2eU+J7 Jngu7vqh7UExFb3nhEMLlTOXdAR+KmqzsBVFcM7yoD22Yms/TyQb8eMaPFYQnFq2pKal 42QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=UrTWzEhA; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p13-20020a63e64d000000b0055759bb6888si11305247pgj.433.2023.06.29.20.42.40; Thu, 29 Jun 2023 20:42:53 -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=@gmail.com header.s=20221208 header.b=UrTWzEhA; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbjF3D1M (ORCPT + 99 others); Thu, 29 Jun 2023 23:27:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbjF3D1G (ORCPT ); Thu, 29 Jun 2023 23:27:06 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55D1EEE; Thu, 29 Jun 2023 20:27:04 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id 41be03b00d2f7-55b22f82ac8so841772a12.1; Thu, 29 Jun 2023 20:27:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688095624; x=1690687624; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OwJdxtfFrP5LDWYvOjXG/8S5IIrimErpt5RB/JNheSE=; b=UrTWzEhAs+uDg/yjovT/P0+gJNzpklPq6m6cKjIR9AkFka1gxu6fSuoNLtS02ceZt5 guvmJSGfqM+wli3R8srIWUDG/ULFMgjCXBhS6c2x2/9YdHZQXdprWL44spcBbfwwbCFH qGVytoTEluJAu7j8se2b4EYnT4WVNd161B3hozIsfJC0N7T2pZ1CvDkP4sHI5LshBLwo u4rHTdrhmFPDNRSIjQqMzuLG92GKAU8oz0nLBLlpJ4TFYshlkaA/D6B17JbANgJhpzbt qXYdwyQ9bU+iQqMOCTOypa3WRpJL8LzpClPSZfLxO/KkP41E2eQCfnh8arYosv6cc4m4 lBww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688095624; x=1690687624; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OwJdxtfFrP5LDWYvOjXG/8S5IIrimErpt5RB/JNheSE=; b=UBjnKgpNTOPqsawAqOdfli9QbpesNrPg00z8qSmgUAfX8r3fEGMRhdmhyweeGi56Yy KsDTuiVqgmoN7EXRClYvaG/fRTIuZmYENo7EC0fXm7gePAeixBEKqTXzuIEEYsSzxkKl q6Cl9RJYrnLYb7mcWMF/08fOEdjL/cq/s8ufYN/CWywgvP6N9QInONia1hlDlvv//oeh 5DCVeKrSRD9WCiWZo1VTaM+1KkibH9eXV5BO7uefGllkA+5vo1nG51884pUfQvoqNsPO FYTmU5OB4pGfvetSJ31b5PhkDGUCGa2RxiX4evw+cZnRDYd69YKXlw3VMJZyr5KjzOid mZeg== X-Gm-Message-State: AC+VfDyCsV9c/4UuP0p3gs+LjvHt02YEKy0lg1zyL50CW6MWTDQ8Pa6N WLpNj/TzZZpYDH3B8TkDov0= X-Received: by 2002:a17:90b:1c04:b0:262:f550:6413 with SMTP id oc4-20020a17090b1c0400b00262f5506413mr7931207pjb.6.1688095623692; Thu, 29 Jun 2023 20:27:03 -0700 (PDT) Received: from MSCND1355B05.fareast.nevint.com ([183.242.39.186]) by smtp.gmail.com with ESMTPSA id x2-20020a17090a294200b00262ca945cecsm10311911pjf.54.2023.06.29.20.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jun 2023 20:27:03 -0700 (PDT) From: Zqiang To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, qiang.zhang1211@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: Destroy previously created kthreads after failing to set napi threaded mode Date: Fri, 30 Jun 2023 11:26:53 +0800 Message-Id: <20230630032653.26426-1-qiang.zhang1211@gmail.com> X-Mailer: git-send-email 2.17.1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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 When setting 1 to enable napi threaded mode, will traverse dev->napi_list and create kthread for napi->thread, if creation fails, the dev->threaded will be set to false and we will clear NAPI_STATE_THREADED bit for all napi->state in dev->napi_list, even if some napi that has successfully created the kthread before. as a result, for successfully created napi kthread, they will never be used. This commit therefore destroy previously created napi->thread if setting napi threaded mode fails. Signed-off-by: Zqiang --- net/core/dev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 69a3e544676c..9929f0567150 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -6317,10 +6317,13 @@ int dev_set_threaded(struct net_device *dev, bool threaded) * This should not cause hiccups/stalls to the live traffic. */ list_for_each_entry(napi, &dev->napi_list, dev_list) { - if (threaded) + if (threaded) { set_bit(NAPI_STATE_THREADED, &napi->state); - else + } else { clear_bit(NAPI_STATE_THREADED, &napi->state); + if (napi->thread) + kthread_stop(napi->thread); + } } return err; -- 2.17.1