Thread (16 messages) read the whole thread 16 messages, 6 authors, 2019-06-11

Re: [RFC V3] mm: Generalize and rename notify_page_fault() as kprobe_page_fault()

From: Anshuman Khandual <hidden>
Date: 2019-06-10 04:36:28
Also in: linux-arm-kernel, linux-mm, linux-s390, linux-sh, lkml, sparclinux


On 06/07/2019 08:36 PM, Dave Hansen wrote:
On 6/7/19 3:34 AM, Anshuman Khandual wrote:
quoted
+static nokprobe_inline bool kprobe_page_fault(struct pt_regs *regs,
+					      unsigned int trap)
+{
+	int ret = 0;
+
+	/*
+	 * To be potentially processing a kprobe fault and to be allowed
+	 * to call kprobe_running(), we have to be non-preemptible.
+	 */
+	if (kprobes_built_in() && !preemptible() && !user_mode(regs)) {
+		if (kprobe_running() && kprobe_fault_handler(regs, trap))
+			ret = 1;
+	}
+	return ret;
+}
Nits: Other that taking the nice, readable, x86 one and globbing it onto
a single line, looks OK to me.  It does seem a _bit_ silly to go to the
trouble of converting to 'bool' and then using 0/1 and an 'int'
internally instead of true/false and a bool, though.  It's also not a
Changing to 'bool'...
horrible thing to add a single line comment to this sucker to say:

/* returns true if kprobes handled the fault */
Picking this in-code comment.
In any case, and even if you don't clean any of this up:

Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Thanks !
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help