Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1714023lqt; Wed, 20 Mar 2024 11:42:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOVbK5fsZ6MfbZ9gKokWnw1oANyKFWhg6GIRQJ2uvftBJGvJ+DvFql326H/+L0WrKT8OK4gnytsB5vc6eZ6EjqT9BqlJQsoAXeUaozCw== X-Google-Smtp-Source: AGHT+IE7pHD4iYTmcOWVno9edSan6h97edz5vs80ry4TATCitCA5uHhcVx0Cmxqc3lusgIiwJkCZ X-Received: by 2002:ac8:5fc5:0:b0:430:e3ec:918 with SMTP id k5-20020ac85fc5000000b00430e3ec0918mr6500896qta.39.1710960173538; Wed, 20 Mar 2024 11:42:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710960173; cv=pass; d=google.com; s=arc-20160816; b=iRDbqf/RfVlIsPr0y6a/BVNZmWIrMoNleUofmWpHAwP3+WBnsbowcv2LvEd3zc1Kuf SNz6GQoXOPG8o8Ev72fawLvZGb358aOr+eZSPES2z16KAsQcYUCtJ8e14oUrBfr2MvQM mbXxAi1BhonzRfpCHflbY5QpFSZU+vYiFADMEmwf4vXxBXjh4qAeiovErvkcU/nEZlMZ rFgkhmJQXhniuqW54ccSFf4Mbho4sis7HO3YVZDQC30ONd42x4LEBPNIpNPHxggUfaru sZHGYN6iaQ33CG+ITqW5D42vj8mXkLQicdC053niAjMUJVotEG0iOiQFwfikZ6wdQfO9 VpwA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=9T8NIbVnKTw/+SDtbAcR9JXgEW/35YMIJ2B57Csnnh4=; fh=68MqnwOHU9sEZcBqWW48XJlUyIcOhprdaYYfIlJa1ls=; b=wpdhKFveOU/abctsO0Clc6cDK+S/2DfoRLn+clchVX2eQP3PeJvAaTeHKqWgP0gbIn E63a4wcC319i/77K7QId4MUKavuP6kssca16VsDgB0QtOhys0/Cd7yxVqOlR/JCkoj+j K1C/BeOsECsPL2zr+vg4NT4C14hfwDLqNorE7wQTUs1+LIlMh1PEmCU/9oaCTHbI00b/ K115vBqY4i3B+zVXDkwbw2dbiTZhWHcBhhiaI7tsm77eZz2V+kTkbSFDyuoZyRDS5wSz DrbdVygEKT4AUzmtUCZ1twyKHNJFbXJlsH31PapedT/lPWPkvdHmROsq8byqVSrfwcEE nw3g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=Wsrfpeoy; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-109304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109304-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id ci25-20020a05622a261900b0042f2127fa75si11894744qtb.683.2024.03.20.11.42.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 11:42:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-109304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=Wsrfpeoy; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-109304-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-109304-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 393681C211F1 for ; Wed, 20 Mar 2024 18:42:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A730685643; Wed, 20 Mar 2024 18:42:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="Wsrfpeoy" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55E8E6A8A6; Wed, 20 Mar 2024 18:42:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710960155; cv=none; b=WWd/4Rg4oi89Or+lESFybS64+iCgNPeI8Axd320s8+4AbVxqNHqi0sSgADl7zT4KDstQvOXT1ag26JjKMsgIZGUDoNsR/7OGLgfJ+Z5EBbqpFNLTeRhe4A3uoaG4Ikun8CZbRDIl7nH2dbB0IF7LHGAb62KsLZLeLhFurYrzx9M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710960155; c=relaxed/simple; bh=mSf36M6+ozi+UXP0kZAkJzy6JWKv6y+KNFAS3NVr9Ac=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TZcAwxoT7gfewGmLPMFHnUBjZ5McaTYu+OXdwmi7ac92Ug7Sq6tHUM0tNORTt+LpfFsfh55BKyxMtsedH8mmpry+0VHchT1lVqeDTxH8NJTjfKbMJX+fVHXwZWd2xFci3cWu+0FEiDlyeR1uH9ZDJr75cORZZQ1Jp1A6V54Kd3I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=Wsrfpeoy; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1710959731; bh=mSf36M6+ozi+UXP0kZAkJzy6JWKv6y+KNFAS3NVr9Ac=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=WsrfpeoyxWE2YmTBNvU2aOHGgVke3371rbcgM0PKWWtn6uurUbyyxpcwJRwFuJNcj IG1TnFE8lpsubpUh/p1Q7qO1JvoWAcDHEa/3oThNNdG9OHn41efq05pcRD289m33w9 vscBeHvYsWJ8ZOXbEMwi72qmAAgusZYKrYukLeDnaSTJtLOpt+f2ZtDCTNX8zNEw8t 3ZwB1OaWs2XMN9Lc7X/ohwP8WVwD4IN/158A/fRqaeOKMFBQi7OzUFm/VqtHwMWkOO MqxkGIoxvDTU3r1egQoAJej/C7+wT7z7Cds9wtgojdx7FyDq8eviXM8K2RPBDB4/qc Adwz7YeiF+faw== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4V0HMl5D2Yzkh9; Wed, 20 Mar 2024 14:35:31 -0400 (EDT) Message-ID: <07272f98-859b-4a10-9096-9cba763af429@efficios.com> Date: Wed, 20 Mar 2024 14:35:52 -0400 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC][PATCH] tracing: Introduce restart_critical_timings() Content-Language: en-US To: Steven Rostedt Cc: LKML , Linux Trace Kernel , Masami Hiramatsu , Daniel Bristot de Oliveira , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Will Deacon , Waiman Long , Boqun Feng , linux-rt-users References: <20240320122012.2c1f461f@gandalf.local.home> <0015569b-15dc-4ccd-b322-67c3665c585e@efficios.com> <20240320135819.4a25c50f@gandalf.local.home> From: Mathieu Desnoyers In-Reply-To: <20240320135819.4a25c50f@gandalf.local.home> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-03-20 13:58, Steven Rostedt wrote: > On Wed, 20 Mar 2024 13:15:39 -0400 > Mathieu Desnoyers wrote: > >>> I would like to introduce restart_critical_timings() and place it in >>> locations that have this behavior. >> >> Is there any way you could move this to need_resched() rather than >> sprinkle those everywhere ? > > Because need_resched() itself does not mean it's going to schedule > immediately. I looked at a few locations that need_resched() is called. > Most are in idle code where the critical timings are already handled. > > I'm not sure I'd add it for places like mm/memory.c or drivers/md/bcache/btree.c. > > A lot of places look to use it more for PREEMPT_NONE situations as a open > coded cond_resched(). > > The main reason this one is particularly an issue, is that it spins as long > as the owner is still running. Which may be some time, as here it was 7ms. What I think we should be discussing here is how calling need_resched() should interact with the latency tracked by critical timings. AFAIU, when code explicitly calls need_resched() in a loop, there are two cases: - need_resched() returns false: This means the loop can continue without causing long latency on the system. Technically we could restart the critical timings at this point. - need_resched() returns true: This means the loop should exit quickly and call the scheduler. I would not reset the critical timings there, as whatever code is executed between need_resched() returning true and calling the scheduler is adding to latency. Having stop/start critical timings around idle loops seems to just be an optimization over that. As for mm and driver/md code, what is wrong with doing a critical timings reset when need_resched() returns false ? It would prevent a whole class of false-positives rather than playing whack-a-mole with those that pop up. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com