From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4204DC46467 for ; Wed, 11 Jan 2023 07:33:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235723AbjAKHdm (ORCPT ); Wed, 11 Jan 2023 02:33:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45032 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231655AbjAKHdX (ORCPT ); Wed, 11 Jan 2023 02:33:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04FABEE1C; Tue, 10 Jan 2023 23:32:46 -0800 (PST) Date: Wed, 11 Jan 2023 08:32:42 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673422364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gnoU21dfZfsK7C0/T0w43z6dHTJwm4LjhRe84LVnovc=; b=C4/Q8vhFsvczuz3F7lCwXRE7Kax3e3/iOgNv2TBHeSnt2osUnM7/gJEy4he4Eyuu5FAg9X MynEv4LQhsgTO6tMFsJaEuK1Y65xA1bA4BwVXgOZ0aQTjB0psCpPub0J0QEvhzw0aQiXhi 4NamsFOPdVRXFLpKBvyTvVW5vE6Whyf7oWuQja5kVXSFR/gh7ReCgqEtO4R2EMzQcJEG7z ofvsxZ3kwTU7KGgCpSLm+0OYk6dHfaLWCsQ3YXyPVzPqkGldJy0kdDfOzROKQbT8bQPN4T fEYEZc0SGwOHhugoYdEZkz/NCvDh8QPv8H9Mpvvg6hXHw47HPgB5EPaXI7A7nA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673422364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=gnoU21dfZfsK7C0/T0w43z6dHTJwm4LjhRe84LVnovc=; b=pONzYW/ACL5x1qcAUiz659Mc3zO7GWVpAkVHf4xw784apW4P8rAK5s973yfO3e9kk/8G3a q6w3wPXEBvBV95Ag== From: Sebastian Andrzej Siewior To: Wei Wang Cc: Jakub Kicinski , Eric Dumazet , =?utf-8?B?5p2O5ZOy?= , davem@davemloft.net, pabeni@redhat.com, imagedong@tencent.com, kuniyu@amazon.com, petrm@nvidia.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] net/dev.c : Remove redundant state settings after waking up Message-ID: References: <20230110091409.2962-1-sensor1010@163.com> <20230110163043.069c9aa4@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 2023-01-10 16:42:56 [-0800], Wei Wang wrote: > I was not able to see the entire changelog, but I don't think > > - set_current_state(TASK_INTERRUPTIBLE); > is redundant. > > It makes sure that if the previous if statement: > if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) > is false, this napi thread yields the CPU to other threads waiting to > be run by calling schedule(). It made sense in the beginning but now the suggested patch is a clean up. First the `woken' parameter was added in commit cb038357937ee ("net: fix race between napi kthread mode and busy poll") and then the `napi_disable_pending' check was removed in commit 27f0ad71699de ("net: fix hangup on napi_disable for threaded napi") which renders the code to: | while (!kthread_should_stop()) { | if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken) { | WARN_ON(!list_empty(&napi->poll_list)); | __set_current_state(TASK_RUNNING); | return 0; | } | | schedule(); | /* woken being true indicates this thread owns this napi. */ | woken = true; | set_current_state(TASK_INTERRUPTIBLE); | } | __set_current_state(TASK_RUNNING); so when you get out of schedule() woken is set and even if NAPI_STATE_SCHED_THREADED is not set, the while() loop is left due to `woken = true'. So changing state to TASK_INTERRUPTIBLE makes no sense since it will be set back to TASK_RUNNING cycles later. Sebastian