Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934891Ab3E1REp (ORCPT ); Tue, 28 May 2013 13:04:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54608 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934848Ab3E1REo (ORCPT ); Tue, 28 May 2013 13:04:44 -0400 Date: Tue, 28 May 2013 19:00:48 +0200 From: Oleg Nesterov To: Vince Weaver Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Paul Mackerras , Ingo Molnar , Arnaldo Carvalho de Melo , trinity@vger.kernel.org, =?iso-8859-1?Q?Fr=E9d=E9ric?= Weisbecker Subject: Re: WARN_ONCE in arch/x86/kernel/hw_breakpoint.c Message-ID: <20130528170048.GA26906@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1926 Lines: 59 Well. I am not familiar with this code, and when I tried to read it I feel I will be never able to understand it ;) On 05/20, Vince Weaver wrote: > > on 3.10-rc1 with the trinity fuzzer patched to exercise the > perf_event_open() syscall I am triggering this WARN_ONCE: > > [ 75.864822] ------------[ cut here ]------------ > [ 75.864830] WARNING: at arch/x86/kernel/hw_breakpoint.c:121 arch_install_hw_breakpoint+0x5b/0xcb() ... > [ 75.864916] [] ? arch_install_hw_breakpoint+0x5b/0xcb > [ 75.864919] [] ? event_sched_in+0x68/0x11c I am wondering if we should check attr->pinned before WARN_ONCE... But it seems that hw_breakpoint.c is buggy anyway. Suppose that attr.task != NULL and event->cpu = -1. __reserve_bp_slot() tries to calculate slots.pinned and calls fetch_bp_busy_slots(). In this case fetch_bp_busy_slots() does for_each_online_cpu(cpu) ... nr += task_bp_pinned(cpu, bp, type); And task_bp_pinned() (in particular) checks cpu == event->cpu, this will be never true. IOW, it seems that __reserve_bp_slot(task, cpu => -1) always succeeds because task_bp_pinned() returns 0 and thus we can create more than HWP_NUM breakpoints. Much more ;) As for _create, I guess we probably need something like --- x/kernel/events/hw_breakpoint.c +++ x/kernel/events/hw_breakpoint.c @@ -156,7 +156,7 @@ fetch_bp_busy_slots(struct bp_busy_slots if (!tsk) nr += max_task_bp_pinned(cpu, type); else - nr += task_bp_pinned(cpu, bp, type); + nr += task_bp_pinned(-1, bp, type); if (nr > slots->pinned) slots->pinned = nr; But I simply can't understand toggle_bp_task_slot()->task_bp_pinned(). Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/