From: Oleg Nesterov <oleg@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Liao Chang <liaochang1@huawei.com>,
mhiramat@kernel.org, peterz@infradead.org, mingo@redhat.com,
acme@kernel.org, namhyung@kernel.org, mark.rutland@arm.com,
alexander.shishkin@linux.intel.com, jolsa@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
kan.liang@linux.intel.com, andrii.nakryiko@gmail.com,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-perf-users@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v5 1/2] uprobes: Remove redundant spinlock in uprobe_deny_signal()
Date: Fri, 24 Jan 2025 18:25:36 +0100 [thread overview]
Message-ID: <20250124172435.GB13891@redhat.com> (raw)
In-Reply-To: <20250124102702.6ff0ccc5@gandalf.local.home>
On 01/24, Steven Rostedt wrote:
>
> On Fri, 24 Jan 2025 09:38:25 +0000
> Liao Chang <liaochang1@huawei.com> wrote:
>
> > Since clearing a bit in thread_info is an atomic operation, the spinlock
> > is redundant and can be removed, reducing lock contention is good for
> > performance.
>
> Although this patch is probably fine, the change log suggests a dangerous
> precedence. Just because clearing a flag is atomic, that alone does not
> guarantee that it doesn't need spin locks around it.
Yes. And iirc we already have the lockless users of clear(TIF_SIGPENDING)
(some if not most of them look buggy). But afaics in this (very special)
case it should be fine.
See also https://lore.kernel.org/all/20240812120738.GC11656@redhat.com/
> There may be another path that tests the flag within a spin lock,
Yes, retarget_shared_pending() or the complete_signal/wants_signal loop.
That is why it was decided to take siglock in uprobe_deny_signal(), just
to be "safe".
But I still think this patch is fine. The current task is going to execute
a single insn which can't enter the kernel and/or return to the userspace
before it calls handle_singlestep() and restores TIF_SIGPENDING. We do not
care if it races with another source of TIF_SIGPENDING.
The only problem is that task_sigpending() from another task can "wrongly"
return false in this window, but I don't see any problem.
Oleg.
next prev parent reply other threads:[~2025-01-24 17:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 9:38 [PATCH v5 0/2] uprobes: Improve scalability by reducing the contention on siglock Liao Chang
2025-01-24 9:38 ` [PATCH v5 1/2] uprobes: Remove redundant spinlock in uprobe_deny_signal() Liao Chang
2025-01-24 15:27 ` Steven Rostedt
2025-01-24 17:25 ` Oleg Nesterov [this message]
2025-01-24 17:38 ` Oleg Nesterov
2025-01-24 9:38 ` [PATCH v5 2/2] uprobes: Remove the spinlock within handle_singlestep() Liao Chang
2025-01-27 11:28 ` [PATCH v5 0/2] uprobes: Improve scalability by reducing the contention on siglock Peter Zijlstra
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=20250124172435.GB13891@redhat.com \
--to=oleg@redhat.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=andrii.nakryiko@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=liaochang1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
/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).