From: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>
To: Jiri Pirko <jiri@resnulli.us>
Cc: linux-pm@vger.kernel.org, "Rafael J. Wysocki" <rafael@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Ricardo Neri <ricardo.neri-calderon@linux.intel.com>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org
Subject: Re: [PATCH 3/3] thermal: intel: hfi: Enable interface only when required
Date: Mon, 5 Feb 2024 13:00:46 +0100 [thread overview]
Message-ID: <ZcDN7ovejiXe754i@linux.intel.com> (raw)
In-Reply-To: <Zb48Z408e18QgsAr@nanopsycho>
On Sat, Feb 03, 2024 at 02:15:19PM +0100, Jiri Pirko wrote:
> Fri, Feb 02, 2024 at 02:00:46PM CET, stanislaw.gruszka@linux.intel.com wrote:
> >On Fri, Feb 02, 2024 at 01:36:09PM +0100, Jiri Pirko wrote:
> >> Wed, Jan 31, 2024 at 01:05:35PM CET, stanislaw.gruszka@linux.intel.com wrote:
> >>
> >> [...]
> >>
> >>
> >> >+static int hfi_netlink_notify(struct notifier_block *nb, unsigned long state,
> >> >+ void *_notify)
> >> >+{
> >> >+ struct netlink_notify *notify = _notify;
> >> >+ struct hfi_instance *hfi_instance;
> >> >+ smp_call_func_t func;
> >> >+ unsigned int cpu;
> >> >+ int i;
> >> >+
> >> >+ if (notify->protocol != NETLINK_GENERIC)
> >> >+ return NOTIFY_DONE;
> >> >+
> >> >+ switch (state) {
> >> >+ case NETLINK_CHANGE:
> >> >+ case NETLINK_URELEASE:
> >> >+ mutex_lock(&hfi_instance_lock);
> >> >+
> >>
> >> What's stopping other thread from mangling the listeners here?
> >
> >Nothing. But if the listeners will be changed, we will get next notify.
> >Serialization by the mutex is needed to assure that the last setting will win,
> >so we do not end with HFI disabled when there are listeners or vice versa.
>
> Okay. Care to put a note somewhere?
I would if the flow would stay the same. But it was requested by Jakub to use
netlink bind/unbind, and this will not work the way described above any longer,
since bind() is before listeners change and unbind() after:
if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) {
err = nlk->netlink_bind(sock_net(sk), val);
if (err)
return err;
}
netlink_table_grab();
netlink_update_socket_mc(nlk, val,
optname == NETLINK_ADD_MEMBERSHIP);
netlink_table_ungrab();
if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind)
nlk->netlink_unbind(sock_net(sk), val)
To avoid convoluted logic or new global lock, I'll use properly protected
local counter increased on bind and decreased on unbind.
Regards
Stanislaw
prev parent reply other threads:[~2024-02-05 12:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-31 12:05 [PATCH 0/3] thermal/netlink/intel_hfi: Enable HFI feature only when required Stanislaw Gruszka
2024-01-31 12:05 ` [PATCH 1/3] netlink: Add notifier when changing netlink socket membership Stanislaw Gruszka
2024-02-01 1:40 ` Jakub Kicinski
2024-02-01 13:10 ` Stanislaw Gruszka
2024-01-31 12:05 ` [PATCH 2/3] thermal: netlink: Export thermal_group_has_listeners() Stanislaw Gruszka
2024-01-31 12:05 ` [PATCH 3/3] thermal: intel: hfi: Enable interface only when required Stanislaw Gruszka
2024-02-01 1:48 ` Ricardo Neri
2024-02-01 13:20 ` Stanislaw Gruszka
2024-02-01 16:21 ` Ricardo Neri
2024-02-02 12:36 ` Jiri Pirko
2024-02-02 13:00 ` Stanislaw Gruszka
2024-02-03 13:15 ` Jiri Pirko
2024-02-05 12:00 ` Stanislaw Gruszka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZcDN7ovejiXe754i@linux.intel.com \
--to=stanislaw.gruszka@linux.intel.com \
--cc=daniel.lezcano@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rafael@kernel.org \
--cc=ricardo.neri-calderon@linux.intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).