Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp590464pxb; Wed, 27 Jan 2021 16:03:31 -0800 (PST) X-Google-Smtp-Source: ABdhPJzf3izdqpiYkATTsmUD3FIVcb7kIGLHQUJJpjDCA6Vd3r6+CNaOJqsOTot/uRS+qUBVg09w X-Received: by 2002:a17:906:6d49:: with SMTP id a9mr8957263ejt.32.1611792211440; Wed, 27 Jan 2021 16:03:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792211; cv=none; d=google.com; s=arc-20160816; b=ADd6s/Ymtzbb1ZThriPq1reLYiWCGBQOLkI+VDgcerRQcmRbev46wmaSvwfTexXRXh t3J0YhztUo576AEVmw5+BzaymG+51NS26ipQ01kxqQrU/8hZUuLBDbiIEJEtTGxSz/4p ZsXEk+VpLlkgAQfotXLLF3af5L/GoQbhfFXiqD37Xunz/5WPkslJKojY+Jb6vI/rxeVO uOh0fJdBawzYhLnnaO+NRAjkGEFSDffLrQFgmVcGVfSUH9+KJNkACh+voL7kae9FnoRq Zp9r02MjQtpIP2G7IkYrybu7bye6hb2VYrW6qDKONNWVBcds4vBUVmyWjFvA0tDweB4U BPGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=9fZk6ao3kK+Vf2upVVBKyx0L4ZHc8YxplCPZEB7EkGQ=; b=BdD9j/EIOVy/5Q0YMIkFbXxzFQgu40ZdKVX47E65vS22FIXBL5VFwP7JjHX6loPnzB BHlq9+NQG+n5qkYzRDFgFbebCAppqkS506/Uy+TYuwaI8lu6Rg2kAuhpKuRoiFnd1YfY toqJhUp8/W4qXL28TPYw3ufLkhx1xCbf8uMH5rga2RTkZtLLqNPMw4TNiBLK2MlGp9y9 kLioXN6Rz5/Is+0RGqIukINepHQRI/Tl1g+WOri232XhNI0AuWq8ieFLmlXAWDIPNRvu 8koPpT2Qa3QQjb5DdOTxKsSK8oYyddeAsndeRo6Ru5L0Sc8vw/xYxpZMuO6hX2ZlS+tb EGfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b5rOpIwo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j22si1727195edh.496.2021.01.27.16.03.07; Wed, 27 Jan 2021 16:03:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b5rOpIwo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235735AbhA0P2a (ORCPT + 99 others); Wed, 27 Jan 2021 10:28:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:33292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235947AbhA0PZm (ORCPT ); Wed, 27 Jan 2021 10:25:42 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id DB0F12079A; Wed, 27 Jan 2021 15:24:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611761095; bh=N/crltNexwHEXchsD2q0bvSIe5NqkUOz1TcVKBPZ23I=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b5rOpIwoQNH7Gso4fViMgvng6uZggBjoGqjsCRFqzVY+mzTEReMcXj06fDyz3K2Pi lF5+NfEMbEY1MyrWdnbGUdHgFwH5SCrZFvwWyWeLJiq0Gka9/F951mytuX8UUI1QI6 44OYyi2kKMzZ/atsfF8rYrjTe6efeDIlcbnGHunFwMVh/LkARf8Eheg0HRzH4jvSpq CZgvfn50U0h3F72PDu8CbZAURFGAYU3G0UmlKU/MuCXz6IUtitj+JZpWB9smM2VNBL KyaPZTbIXoyjwfkCYeedU1ti4KoZsp3jZwh/JTIx/gCUF7u/iF1TQrhAPjr5Xtl/SG Xra3p/8n4fAyA== Date: Thu, 28 Jan 2021 00:24:52 +0900 From: Masami Hiramatsu To: Masami Hiramatsu Cc: Nikolay Borisov , Peter Zijlstra , LKML Subject: Re: kprobes broken since 0d00449c7a28 ("x86: Replace ist_enter() with nmi_enter()") Message-Id: <20210128002452.a79714c236b69ab9acfa986c@kernel.org> In-Reply-To: <20210128001353.66e7171b395473ef992d6991@kernel.org> References: <25cd2608-03c2-94b8-7760-9de9935fde64@suse.com> <20210128001353.66e7171b395473ef992d6991@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 28 Jan 2021 00:13:53 +0900 Masami Hiramatsu wrote: > Hi Nikolay, > > On Wed, 27 Jan 2021 15:43:29 +0200 > Nikolay Borisov wrote: > > > Hello, > > > > I'm currently seeing latest Linus' master being somewhat broken w.r.t > > krpobes. In particular I have the following test-case: > > > > #!/bin/bash > > > > mkfs.btrfs -f /dev/vdc &> /dev/null > > mount /dev/vdc /media/scratch/ > > > > bpftrace -e 'kprobe:btrfs_sync_file {printf("kprobe: %s\n", kstack());}' > > &>bpf-output & > > bpf_trace_pid=$! > > > > # force btrfs_sync_file to be called > > sleep 2 > > xfs_io -f -c "pwrite 0 4m" -c "fsync" /media/scratch/file5 > > > > kill $bpf_trace_pid > > sleep 1 > > > > grep -q kprobe bpf-output > > retval=$? > > rm -f bpf-output > > umount /media/scratch > > > > exit $retval > > > > It traces btrfs_sync_file which is called when fsync is executed on a > > btrfs file, however I don't see the stacktrace being printed i.e the > > kprobe doesn't fire at all. The following alternative program: > > > > bpftrace -e 'tracepoint:btrfs:btrfs_sync_file {printf("tracepoint: > > %s\n", kstack());} kprobe:btrfs_sync_file {printf("kprobe: %s\n", > > kstack());}' > > > > only prints the stack from the tracepoint and not from the kprobe, given > > that the tracepoint is called from the btrfs_sync_file function. > > Thank you for reporting! > > If you don't mind, could you confirm it with ftrace (tracefs)? > bpftrace etc. involves too many things. It is better to test with > simpler way to test it. > I'm not familer with the bpftrace, but I think you can check it with > > # cd /sys/kernel/debug/tracing > # echo p:myevent btrfs_sync_file >> kprobe_events > # echo stacktrace > events/kprobes/myevent/trigger > (or echo 1 > options/stacktrace , if trigger file doesn't exist) Of course, also you have to enable the event. # echo 1 > events/kprobes/myevent/enable And check the results # cat trace > Could you also share your kernel config, so that we can reproduce it? Thank you, > > > > > I started bisecting this and arrived at the following commit: > > > > 0d00449c7a28 ("x86: Replace ist_enter() with nmi_enter()") > > > > FWIW the following series is applied on the kernel I was testing: > > https://lore.kernel.org/lkml/159870598914.1229682.15230803449082078353.stgit@devnote2/ > > > > but it's still broken. > > Peter, would you have any idea? > > Thank you, > > -- > Masami Hiramatsu -- Masami Hiramatsu