Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp99646pxk; Fri, 11 Sep 2020 01:16:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfnpsi4yrcodZeQ9uraWpEIinirxmv62C2e4omoc62HvV4Mna8YSopQDtTd0h+XyWXWUDA X-Received: by 2002:aa7:dd01:: with SMTP id i1mr814378edv.121.1599812173379; Fri, 11 Sep 2020 01:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599812173; cv=none; d=google.com; s=arc-20160816; b=n/eAArwqeL7OREUOkjDqS+cNhJakZODOpYZsWWAQPcDNwXsqRzU11RVdnusukb1WTL cU3hbmbmE9GLhFsk54Oa79pd51OWbdVISWiJkg9Gkfy6K64TKBoWy0Ul8Atlx6zCiVtw Ip/fzfg6hLUB5+GpZKnq/qoRDVvmpAEuvfMY/rR6es07vKVno0L3/lPjFeAsqUrhmD2T zvFY6xyhH4u2cj9P7TI3uM1s6yIDudtVfyjWh1zWsI5q4JluV/5snNIgEXLo9vzIq98H WwTrZEe0cF+KRDiV5K2p4bFSM9x5DOo7Q3PCXJAJY+RkADtQjwxDPA2GTXuK6okeqokd SkJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:feedback-id:mime-version:user-agent :message-id:in-reply-to:date:references:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature; bh=SHB6EtwqSiI8bdVgrRGw5214bO0laV3O8vy7P63nH2Q=; b=OfWfMfLWn3aUPiusvVctCN8j5K5QZXfVma4unE6k4dcIuqjgw1LN+49jTGzRXxT6jo nXXjMAVjmRl5F2wQFSLnl2L4DZQKWgoOUX+ZgYgKh/vHJNTTBUVbaPWsd2Mo+hiTshN4 pIX98AyBwDS4IU+TteeC8kD/RslQlr14p2YNw2Mt/qVIc9A+qsao+tAkFgcGF36AeRjE hw7ur0r2ZR5D+8t/Uetpf97oQVDf1pnyxMmXJ40Zh/c6o/7PSq8yFN2VZ9p9etiVLgeL tc4JAcPcY41P7ZxHuVmTyLO99SaA0aUoaRD3r4EINj4XFNY584FTMv14yqG0HWM6Q5QE oAqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b=k71otVRC; dkim=pass header.i=@amazonses.com header.s=hsbnp7p3ensaochzwyq5wwmceodymuwv header.b=Mgt5ysOY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si793718edr.396.2020.09.11.01.15.38; Fri, 11 Sep 2020 01:16:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@codeaurora.org header.s=zsmsymrwgfyinv5wlfyidntwsjeeldzt header.b=k71otVRC; dkim=pass header.i=@amazonses.com header.s=hsbnp7p3ensaochzwyq5wwmceodymuwv header.b=Mgt5ysOY; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725616AbgIKIPK (ORCPT + 99 others); Fri, 11 Sep 2020 04:15:10 -0400 Received: from a27-21.smtp-out.us-west-2.amazonses.com ([54.240.27.21]:33432 "EHLO a27-21.smtp-out.us-west-2.amazonses.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725535AbgIKIPG (ORCPT ); Fri, 11 Sep 2020 04:15:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=zsmsymrwgfyinv5wlfyidntwsjeeldzt; d=codeaurora.org; t=1599812105; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:MIME-Version:Content-Type; bh=N9fxCc5NW0Ti9oo755ftCoAbiGuKOsIm79KqZGSYUQ4=; b=k71otVRCDW7r9HGYv00Cige9iaFAguYBszjfblGeuzHk/nYHFAyMYR1tgnUDJ2ve N18pCpprXR9cdA8bE6+zQqd97/DwjTaj/J1lNPAicIyA/sZZho73IMNZtlNd0bMUTbb IDrASypERoJEAUIE3PBCM8LdPnLUM9PUMBGSYzmc= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=hsbnp7p3ensaochzwyq5wwmceodymuwv; d=amazonses.com; t=1599812105; h=From:To:Cc:Subject:References:Date:In-Reply-To:Message-ID:MIME-Version:Content-Type:Feedback-ID; bh=N9fxCc5NW0Ti9oo755ftCoAbiGuKOsIm79KqZGSYUQ4=; b=Mgt5ysOYhjhtZaMtVEU2Ha3iY0pLfw6dJYCHwPtRUbM6b89n+yILaRaMvY2gwIFn XjH8LAFzqEgdbnNNzhyx+tovdJ9bP+lBubPexv1hC9Lk9dsPk6tbNi+OLirTC98UeYP Ud1vU3hknvfl8NwACujATwQ+5s3z3isBXjz8glK0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org BA31AC433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Felix Fietkau Cc: linux-wireless@vger.kernel.org Subject: Re: [PATCH 04/11] mt76: add utility functions for deferring work to a kernel thread References: <20200908211756.15998-1-nbd@nbd.name> <20200908211756.15998-4-nbd@nbd.name> Date: Fri, 11 Sep 2020 08:15:05 +0000 In-Reply-To: <20200908211756.15998-4-nbd@nbd.name> (Felix Fietkau's message of "Tue, 8 Sep 2020 23:17:49 +0200") Message-ID: <010101747c3b7518-86af82e8-24bd-41f9-b7e3-8fb181e9d926-000000@us-west-2.amazonses.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-SES-Outgoing: 2020.09.11-54.240.27.21 Feedback-ID: 1.us-west-2.CZuq2qbDmUIuT3qdvXlRHZZCpfZqZ4GtG9v3VKgRyF0=:AmazonSES Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Felix Fietkau writes: > In order to avoid keeping work like tx scheduling pinned to the CPU it was > scheduled from, it makes sense to switch from tasklets to kernel threads. > > Signed-off-by: Felix Fietkau [...] > --- a/drivers/net/wireless/mediatek/mt76/util.c > +++ b/drivers/net/wireless/mediatek/mt76/util.c > @@ -110,4 +110,32 @@ int mt76_get_min_avg_rssi(struct mt76_dev *dev, bool ext_phy) > } > EXPORT_SYMBOL_GPL(mt76_get_min_avg_rssi); > > +int __mt76_worker_fn(void *ptr) > +{ > + struct mt76_worker *w = ptr; > + > + while (!kthread_should_stop()) { > + set_current_state(TASK_INTERRUPTIBLE); > + > + if (kthread_should_park()) { > + kthread_parkme(); > + continue; > + } > + > + if (!test_and_clear_bit(MT76_WORKER_SCHEDULED, &w->state)) { > + schedule(); > + continue; > + } > + > + set_bit(MT76_WORKER_RUNNING, &w->state); > + set_current_state(TASK_RUNNING); > + w->fn(w); > + cond_resched(); > + clear_bit(MT76_WORKER_RUNNING, &w->state); > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(__mt76_worker_fn); So how is this better than, for example, create_singlethread_workqueue()? And if this is better, shouldn't it be part of workqueue.h instead of every driver reinventing the wheel? -- https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches