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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 15 Nov 2012 14:28:18 -0800
From:	Vaibhav Nagarnaik <vnagarnaik@...gle.com>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org,
	Vaibhav Nagarnaik <vnagarnaik@...gle.com>
Subject: [PATCH] kernel-shark: Allow unsetting of all CPUs in filter

The button "All CPUs" in CPU filter dialog allows setting of all CPUs
but doesn't clear CPUs when it is unchecked. Make sure that when the
"All CPUs" button is unchecked, all the CPUs get unchecked.

Tested: In kernelshark, go to Filter->list CPUs and uncheck "All CPUs"
button. All the CPUs should be unchecked at that point.

Change-Id: If7852cc3452177165adf78c42eb1ebc39a253e86

Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@...gle.com>
---
 cpu.h          |   11 +++++++++++
 trace-filter.c |   37 ++++++++++++++++++++++---------------
 2 files changed, 33 insertions(+), 15 deletions(-)

diff --git a/cpu.h b/cpu.h
index 1c2b0d9..05c7f17 100644
--- a/cpu.h
+++ b/cpu.h
@@ -29,6 +29,17 @@ static inline int cpu_isset(guint64 *cpu_mask, gint cpu)
 	return mask & (1ULL << (cpu & ((1ULL << 6) - 1)));
 }
 
+static inline gboolean cpu_allset(guint64 *cpu_mask, gint max_cpus)
+{
+	gint cpu;
+
+	for (cpu = 0; cpu < max_cpus; cpu++) {
+		if (!cpu_isset(cpu_mask, cpu))
+			return FALSE;
+	}
+	return TRUE;
+}
+
 static inline void cpu_set(guint64 *cpu_mask, gint cpu)
 {
 	guint64 *mask;
diff --git a/trace-filter.c b/trace-filter.c
index c657a18..0d50ef9 100644
--- a/trace-filter.c
+++ b/trace-filter.c
@@ -1723,29 +1723,36 @@ void cpu_toggle(gpointer data, GtkWidget *widget)
 
 	if (strcmp(label, CPU_ALL_CPUS_STR) == 0) {
 		cpu_helper->allcpus = active;
-		if (active) {
-			/* enable all toggles */
-			for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
-				gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
-							     TRUE);
-		}
+		/* enable/disable all toggles */
+		for (cpu = 0; cpu < cpu_helper->cpus; cpu++)
+			gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu]),
+						     active ? TRUE : FALSE);
 		return;
 	}
 
 	/* Get the CPU # from the label. Pass "CPU " */
 	cpu = atoi(label + 4);
-	if (active) {
+	if (active)
 		cpu_set(cpu_helper->cpu_mask, cpu);
-		return;
-	}
-
-	cpu_clear(cpu_helper->cpu_mask, cpu);
-
-	if (!cpu_helper->allcpus)
-		return;
+	else
+		cpu_clear(cpu_helper->cpu_mask, cpu);
+
+	cpu_helper->allcpus = cpu_allset(cpu_helper->cpu_mask,
+					 cpu_helper->cpus);
+	/*
+	 * Deactivate sending 'toggled' signal for "All CPUs"
+	 * while we adjust its state
+	 */
+	g_signal_handlers_block_by_func(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu_helper->cpus]),
+				        G_CALLBACK (cpu_toggle),
+				        (gpointer) cpu_helper);
 
 	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu_helper->cpus]),
-				     FALSE);
+				     cpu_helper->allcpus);
+
+	g_signal_handlers_unblock_by_func(GTK_TOGGLE_BUTTON(cpu_helper->buttons[cpu_helper->cpus]),
+					  G_CALLBACK (cpu_toggle),
+					  (gpointer) cpu_helper);
 }
 
 /**
-- 
1.7.7.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ