Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp32754lqc; Thu, 29 Feb 2024 09:31:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVok8nAvQlDmFqYIGNXtM6DrkDb73t2oQyJWYGFnNrR+jiOlPgJhLUGE5Oam5g1bUN4heqjblI9sXe6MbgNMuDMPCgPc1aFd/j7nk7g4w== X-Google-Smtp-Source: AGHT+IGOfi3mUxsx8MHYiruAPlqlmDvMNQiqLdyHsB/aAYl5lINr+490olTTsFdSXhocxhS23PAo X-Received: by 2002:a05:620a:89b:b0:787:bb67:850b with SMTP id b27-20020a05620a089b00b00787bb67850bmr2767231qka.65.1709227879715; Thu, 29 Feb 2024 09:31:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709227879; cv=pass; d=google.com; s=arc-20160816; b=CMp8bAnB75S8tGnG96S/3tZWIt9Vw0C4JbSHB+YuuLbg0nsWyfa97IB6MxtpI0Jmlt i1/7KyV/r9QerNlHZXqnRdF5gSFSvJTW53Ql8RbKYtFeEIA6tmngyfX107L3EdW4qmi4 WMQxDxqfjmvfO2NLFcefADExWprL7mzX+mmB9siaY/wDDeL4y0nKmLJFTnn+UXksboMW qVMXvL1cfWwHP4hKydH5kEWyhGrsnbAYcY3tVqrXp/NTLIJofv2CJrprIgox44tqZ9kh GtaAfhPl07LlKZGesTF4dos8ZG726c2Yyjoj1enTqrTDeQnaUg/IfzidANm/9X1f8O6C 9n3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:in-reply-to:subject:cc:to:dkim-signature :dkim-signature:from; bh=MBZ3N6JJXjlh48m+F+Wmr5K33vvLF5DHDzgoUyYVEx8=; fh=hdyqXtB0bE3ipALk8vQHGy3wa8HG02oTCni/ksVr+vs=; b=tQqnI5Nd2F1SnRpaRRjei/pO2gtxxf4Jufy+thx7bDtrUVevGXxSPDZUAFCtqjycpb en7+QR9N9qZamB5daKvJOTnfqpmVzoPrWdYHjSOSvihYTLAZvYIEhzgxy24MPHviRpOI pol7+n8fFd083lAFqH/KX0Yr1jaaQEmX2OzKpDRhi5Rs5AuCccVLpcChheEiMos60pAZ aqWdtpQtekiX58igZ4DsWRY0j1BncFp2msfViqVxMHcLVT8h4K0IPyzJRFmzl0Hrs4hL DJsQE+VemUuSQJpAd3xooKIKUbNb68aNhqyYv03O/JjyLrBPpJujIMRf/cG6OhSr5yrK CBeA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=201SB3Su; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-87174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id n17-20020a05620a223100b00787bf7af3dbsi1680783qkh.580.2024.02.29.09.31.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:31:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=201SB3Su; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-87174-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 5B23B1C22578 for ; Thu, 29 Feb 2024 17:31:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9F9BD70AD1; Thu, 29 Feb 2024 17:31:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="201SB3Su"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="fimFcHP6" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 B8D4F6CBEB for ; Thu, 29 Feb 2024 17:31:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709227872; cv=none; b=Ovc4yAGrHczoPiHPFA8yU0tLGOZI1Te1IXDVo2EfTG7I9y3uztRw0CuU+c2ZTaGL5tzw/fgpMWFClLsdrbOrpvlzY51ng7ITD/MWaUb0K+ZoaUaihe1upeYGZZ5hHgRQQCw5AT8DC8F3VMdTOHamJFVKsK+1+Tnl2MQwmDj+BxI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709227872; c=relaxed/simple; bh=B3ln6B3b1FKGpz4kZqkRPSpkIwGqt5XO8/XXUGaLxBE=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=unfJZGtmfK7ld20U+PwCJCBde0wpFrwY5WykAlSBw++HN3Lbwsn8MZtQGFWKDeeUzouPPbhWx34lkTxxLsfBNsTO/MlM27musvp5QrstXkbYB4WsmsNJFlZgQhojtNrX/DRvM+Ui9QiYUmXl2RhPd6NZ8trlXalWGXczXOnlW7o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=201SB3Su; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=fimFcHP6; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1709227868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MBZ3N6JJXjlh48m+F+Wmr5K33vvLF5DHDzgoUyYVEx8=; b=201SB3SuYDgHPVFHR3QV6E84Y8i4rnFiCpAFCliTCUUGU5oAfaT705E16WcqjHtVP9VwKe fUG1wy7bqD97ysi/NK2a+sp7ZQFoFpvqII5U/gwLjXm5fJfmszQHdZJwldyMpZiFTITS2O VoziEnyDN+hemZzep0Wb39xB8wTAc2jxS/qw5tuOuGckNILqAyM4xkP80pcL1z4GIfIRHX 8ZaazdNlGypqUWdO2Hyi2OxURRyUkS6c46GBfocPqNR2VAXaGVvyXvH37KY/ZmahBfTBsM Rn4s2zV3Gtc0oG1cEsReebWwkq9aeEEob2UFJt+kC8jBi8sQ4kcmYZkNOSa2xQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1709227868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MBZ3N6JJXjlh48m+F+Wmr5K33vvLF5DHDzgoUyYVEx8=; b=fimFcHP6oXB1AbAIhee09SXluv9+i7soxfl1mXEXCOSS+xnmAiogYxpbojjgd7L4oSNmgL TzCTDtTIhns42OBA== To: Jens Axboe , linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com, Jens Axboe Subject: Re: [PATCH 2/2] sched/core: split iowait state into two states In-Reply-To: <20240228192355.290114-3-axboe@kernel.dk> References: <20240228192355.290114-1-axboe@kernel.dk> <20240228192355.290114-3-axboe@kernel.dk> Date: Thu, 29 Feb 2024 18:31:08 +0100 Message-ID: <87zfvj6uub.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Wed, Feb 28 2024 at 12:16, Jens Axboe wrote: > iowait is a bogus metric, but it's helpful in the sense that it allows > short waits to not enter sleep states that have a higher exit latency > than we would've picked for iowait'ing tasks. However, it's harmless in > that lots of applications and monitoring assumes that iowait is busy > time, or otherwise use it as a health metric. Particularly for async > IO it's entirely nonsensical. > > Split the iowait part into two parts - one that tracks whether we need > boosting for short waits, and one that says we need to account the > task We :) > as such. ->in_iowait_acct nests inside of ->in_iowait, both for > efficiency reasons, but also so that the relationship between the two > is clear. A waiter may set ->in_wait alone and not care about the > accounting. > +/* > + * Returns a token which is comprised of the two bits of iowait wait state - > + * one is whether we're making ourselves as in iowait for cpufreq reasons, > + * and the other is if the task should be accounted as such. > + */ > int io_schedule_prepare(void) > { > - int old_iowait = current->in_iowait; > + int old_wait_flags = 0; > + > + if (current->in_iowait) > + old_wait_flags |= TASK_IOWAIT; > + if (current->in_iowait_acct) > + old_wait_flags |= TASK_IOWAIT_ACCT; > > current->in_iowait = 1; > + current->in_iowait_acct = 1; > blk_flush_plug(current->plug, true); > - return old_iowait; > + return old_wait_flags; > } > > -void io_schedule_finish(int token) > +void io_schedule_finish(int old_wait_flags) > { > - current->in_iowait = token; > + if (!(old_wait_flags & TASK_IOWAIT)) > + current->in_iowait = 0; > + if (!(old_wait_flags & TASK_IOWAIT_ACCT)) > + current->in_iowait_acct = 0; Why? TASK_IOWAIT_ACCT requires TASK_IOWAIT, right? So if TASK_IOWAIT was not set then TASK_IOWAIT_ACCT must have been clear too, no? Thanks, tglx