Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1367833ybn; Wed, 2 Oct 2019 15:09:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOkaNWQSctqkcUcqCX2K8zOSt+vlzBwv13pUfPylQD0LBr7y+Zy/GjB/D1qK/TlfQm3KPl X-Received: by 2002:a50:f78a:: with SMTP id h10mr6327235edn.161.1570054168150; Wed, 02 Oct 2019 15:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570054168; cv=none; d=google.com; s=arc-20160816; b=ppJ5w0nvNLbKp+LT7LpVvVe9n4DYlQrCySSCGIVq0C/vWdyb7r76zYfGjVnxUctp/j 1oJg0iYS2Dk78nN+J2otCv6g4BCKHbhme/BdNIuXfjidMh3gM2UOnFUl7UfrUqkQBxkR uxKNQ90RXRGpk+NZ8azNge8UXN8U53Gxyi6Q6RFZMhncvSFqqMMalqdPzFoaddlPcY7s 32BJqGxEgiQ4YyvlvbpAqYMuXToDlz1o32E8cZzV7X6dR8QjNgJSTJwulNshyCauHb9b kS4f7eJ5T4k9nVDsa29UX+ssl7sdWDZoRqsmjj7fJwrahUlDA2rIJXMPtZkq9f2so4mm uxow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=VUCrdG5Ip3vuddK4QdH3k6TYwm2kGknJubRiy7zVTCU=; b=n7L0ki6Ix+1fiQ8rXmH9kKFgVEROH0gx0bX90/h/qWE0NRDYRkfQLF+2m8ktfkTeIa ml70xSWF/T2WMvESGqsAs5rgw4EyIsX5ot5+QBpTUQ9jrngWCUdImoEcLPeFb7x4OaA/ sb0/D1l/hn2OQiMKi/rzJYE+G/TAdohWpEOPDfgcFhLO/4mItAvGMDM6uN5/zP/dSAF1 Mc10L9HF4YjbhWmFCfWf3FqjPcpdn7VvBam6HZfPjCByvihcrup26bjviIirjyidbhTF EiDNwUAZdWXlwd3Wkj+5ZHaaN2y2/Hr6HsjljxccgwgyYa+B5TjEOcRveP9loPAwgqyP B4qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CU8WRk5Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l45si289492edb.18.2019.10.02.15.09.03; Wed, 02 Oct 2019 15:09:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CU8WRk5Y; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727488AbfJBWFC (ORCPT + 99 others); Wed, 2 Oct 2019 18:05:02 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44223 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726462AbfJBWFB (ORCPT ); Wed, 2 Oct 2019 18:05:01 -0400 Received: by mail-qt1-f195.google.com with SMTP id u40so746650qth.11 for ; Wed, 02 Oct 2019 15:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=VUCrdG5Ip3vuddK4QdH3k6TYwm2kGknJubRiy7zVTCU=; b=CU8WRk5Yufy1cRgHxXBFKYCXF9kzkm0Bkbw0x/T7oKYpOUJ9luYkFV6x3upMhgGY6k RG4mIuoOCxZNeezAJIcLKNWbC5i+nTlFG4hfGyE4BNjqNNJ6MB/+9DTa/+5cSzeG55bB l49szpLC/RAR9jCswbsT3clcCw0Fhcs+S4L1XYdLUwAK56ENrdu8Id56UtI2zMoyc4iw G8tYMjCwNl8PSj4J7lhUkdHsSLurVHqElRzBZ2jDGksLlobtIJWW1HBXSybCk4GlOXOp tuEgy0jBfcOHpoD/Z2phbVPqVpCLshNhsbD8IVsIuOgluHxwd61iQoFBPze2GpOuSU01 /l0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=VUCrdG5Ip3vuddK4QdH3k6TYwm2kGknJubRiy7zVTCU=; b=oibWIDr0oJhF+htNjKuyB9XzKwxb9nbNs3EwM5HQT1rtBF8Fh4REBMiTZYSIErwxIL P+F32ILL5zKzEva5Cen5LYFiBdR58Zk9E2qBxK4wBkTLONE+kszqdq/dhc6GvUICdg0g Qq6j6MwZWVR3JneXKMwsEpudptkr7PUtNEEabF+YxrfZiwkixOp+S3uqAWTgE9hmAftv FaGFUKnngAXb5hOEgRVB5fybPC0UOxrpSc3aGqUbkpB8XwGQmYlwHnXQjCT+phvoMag/ RvBeOUSwu5TF0bTJJBhPQOsbP4J32Qju76oxedDrVkmkUobwzgyoPvml3hcb8K5pQfMA c7RQ== X-Gm-Message-State: APjAAAWXfRYHyas9VshR1LuRSyHrgT/zv866+WJBVmuAwjMBQXeTMjat iZRqwCRpPdIK6CWAn56vOQ== X-Received: by 2002:ac8:4597:: with SMTP id l23mr6897186qtn.284.1570053899632; Wed, 02 Oct 2019 15:04:59 -0700 (PDT) Received: from [192.168.1.99] ([92.117.179.41]) by smtp.googlemail.com with ESMTPSA id d23sm315040qkc.127.2019.10.02.15.04.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Oct 2019 15:04:58 -0700 (PDT) Subject: Re: [PATCH v7 1/4] ftrace: Implement fs notification for tracing_max_latency To: Steven Rostedt Cc: Ingo Molnar , linux-kernel@vger.kernel.org, Joel Fernandes References: <20190920152219.12920-1-viktor.rosendahl@gmail.com> <20190920152219.12920-2-viktor.rosendahl@gmail.com> <20191002111324.7590bf6d@gandalf.local.home> From: Viktor Rosendahl Message-ID: Date: Thu, 3 Oct 2019 00:04:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20191002111324.7590bf6d@gandalf.local.home> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/2/19 5:13 PM, Steven Rostedt wrote: > On Fri, 20 Sep 2019 17:22:16 +0200 > "Viktor Rosendahl (BMW)" wrote: > >> This patch implements the feature that the tracing_max_latency file, >> e.g. /sys/kernel/debug/tracing/tracing_max_latency will receive >> notifications through the fsnotify framework when a new latency is >> available. >> >> One particularly interesting use of this facility is when enabling >> threshold tracing, through /sys/kernel/debug/tracing/tracing_thresh, >> together with the preempt/irqsoff tracers. This makes it possible to >> implement a user space program that can, with equal probability, >> obtain traces of latencies that occur immediately after each other in >> spite of the fact that the preempt/irqsoff tracers operate in overwrite >> mode. >> >> This facility works with the hwlat, preempt/irqsoff, and wakeup >> tracers. >> >> The tracers may call the latency_fsnotify() from places such as >> __schedule() or do_idle(); this makes it impossible to call >> queue_work() directly without risking a deadlock. The same would >> happen with a softirq, kernel thread or tasklet. For this reason we >> use the irq_work mechanism to call queue_work(). > > Can fsnotify() be called from irq context? If so, why have the work > queue at all? Just do the work from the irq_work handler. > fsnotify() might sleep. It calls send_to_group(), which calls inotify_handle_event() through a function pointer. inotify_handle_event() calls kmalloc() without the GFP_ATOMIC flag. There might be other reasons as well but the above is one that I have seen a warning for, when enabling CONFIG_DEBUG_ATOMIC_SLEEP and trying to call fsnotify() from an atomic context. best regards, Viktor