lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y0GEUkLWDvU34h9f@hirez.programming.kicks-ass.net>
Date:   Sat, 8 Oct 2022 16:08:18 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Marco Elver <elver@...gle.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        Jiri Olsa <jolsa@...nel.org>,
        Namhyung Kim <namhyung@...nel.org>,
        linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
        kasan-dev@...glegroups.com, Dmitry Vyukov <dvyukov@...gle.com>
Subject: Re: [PATCH] perf: Fix missing SIGTRAPs

On Sat, Oct 08, 2022 at 03:51:24PM +0200, Peter Zijlstra wrote:
> On Fri, Oct 07, 2022 at 03:58:03PM +0200, Marco Elver wrote:
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 9319af6013f1..7de83c42d312 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -2285,9 +2285,10 @@ event_sched_out(struct perf_event *event,
> >  			 */
> >  			local_dec(&event->ctx->nr_pending);
> >  		} else {
> > -			WARN_ON_ONCE(event->pending_work);
> > -			event->pending_work = 1;
> > -			task_work_add(current, &event->pending_task, TWA_RESUME);
> > +			if (!event->pending_work) {
> > +				event->pending_work = 1;
> > +				task_work_add(current, &event->pending_task, TWA_RESUME);
> > +			}
> 			  else {
> 				local_dec(&event->ctx->nr_pending);
> 			}
> >  		}
> >  	}
> 
> That whole thing can be written much saner like:
> 
> 	if (event->pending_sigtrap) {
> 		event->pending_sigtrap = 0;
> 		if (state != PERF_EVENT_STATE_OFF &&
> 		    !event->pending_work) {
> 			event->pending_work = 1;
> 			local_inc(&event->ctx->nr_pending);
> 			task_work_add(current, &event->pending_task, TWA_RESUME);
> 		}
> 		local_dec(&event->ctx->nr_pending);
> 	}
> 
> Except now we have two nr_pending ops -- I'm torn.

I've settled for:

+       if (event->pending_sigtrap) {
+               bool dec = true;
+
+               event->pending_sigtrap = 0;
+               if (state != PERF_EVENT_STATE_OFF &&
+                   !event->pending_work) {
+                       event->pending_work = 1;
+                       dec = false;
+                       task_work_add(current, &event->pending_task, TWA_RESUME);
+               }
+               if (dec)
+                       local_dec(&event->ctx->nr_pending);
+	}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ