Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp41710lqc; Thu, 29 Feb 2024 09:46:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5UW6KOoLpjgKF8mxvIaiH9wqYZtFxK7mOrI8LIW9iuknJPcdRFV5uZKdJXnwAO2rnbZggPoyX/OAttIo79Y/D8Mh/3Hxsk1d2rWi58g== X-Google-Smtp-Source: AGHT+IFeT73F+YBc5q0pnIRWY8zc6h+7kXtY7pQbpqP9v2uPIThft4+/fYVah2CqAGc/Ay77nDTr X-Received: by 2002:a17:90a:9315:b0:29a:68ad:b77e with SMTP id p21-20020a17090a931500b0029a68adb77emr2636327pjo.19.1709228763475; Thu, 29 Feb 2024 09:46:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709228763; cv=pass; d=google.com; s=arc-20160816; b=EQKZDdxF6D56SVIHMqxoQvAAfxqvOd9AZvl50nt4xonJqouDvioM0GNnp894AuNS9z TJUiA5tNJtyaOQx6GQr4c/N9QAUFIKO1rz16MSyUoOBec5cFxTO93qQ60wB8oG2qoxxl P9pDHF7UqSaZHrCIY5w6jCxtJx7JhCUK6TQzjjFUZNS4TvcuRJ1LjV+jvpwzexxGskUk 77a0eQwQYiz2+6QH6NTqUGAH9t3w8zosziArEmXH4icquX1pYZsdC9r6TkscjAFrjhc/ 9S+WrJsU5FtmkgPTe4aaYxqpZwIJ/LwFjPNRF0JIFNbhwsgMbty3Q67vaFRvoa3PgCs0 sjiQ== 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=DZQJSc0KZQA8CADa/JynBw1thTIXDFhC1Jy7qGrAIwA=; fh=odbvm1/Vboav1fHTAPLN4sGl1Ui93omQJ8Z0NPZCb/4=; b=tI1xsiJz76aoxrF9RmMHYWzfpx2oR2125zh9twnT4r5mM3dA5M+f1pkbZAwKc6gvTG 9c7nyIEZjVfSbZO5ZPqafQzVSwuDxm5NOka3RXQ47j6FptXvG+SWapKzeSPrHJ7WmrTx 5zl9+BJcaupafPpK8rXMj7O+VPpvudWKujZ/ZcobD6Z1WOgf4NKUGrfOKiBzrRkjQ2zq 2mn2BtNeSljcJcjE6Bi0kz7tt90HSqA8KX/jtlzp5hxQ3EJ4mU472lsGtjXpJ+4As5Zo OAEWV+6Ly6vsYIuYlqas0xlNBfmhrKEQ/0TLHIq3Ql9QfLln6NfdHtXWcAaQ9VM7lesa qhDQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=gafe5F1r; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-87206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87206-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id rj10-20020a17090b3e8a00b00295dc06ddb6si1922463pjb.129.2024.02.29.09.46.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:46:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=gafe5F1r; arc=pass (i=1 spf=pass spfdomain=kernel.dk dkim=pass dkdomain=kernel-dk.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-87206-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87206-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0232628E6C5 for ; Thu, 29 Feb 2024 17:46:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DA1CC75812; Thu, 29 Feb 2024 17:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="gafe5F1r" Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A94D470AE9 for ; Thu, 29 Feb 2024 17:45:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709228745; cv=none; b=DZITTMihQ5yESv8h3ypQahiapR5vZ9UWAswvgbENGN06YQ8frwAbJTw0Wwdv7wX44e1j1FhTr84XovCSC0QKxid06DQSE/kFMGvvJHj0gkiRU6VbgILt0DPSswvSEZjahT5a57k59h8u4SLOlRcOakAPzrC2AUvgy4gZ5C5V9CE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709228745; c=relaxed/simple; bh=UCT6hn55RHePrDjuP9w0kS4PQbVHPbf2DK1bkX75CjM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WxBKgp2klpqwQYxsq1yp8G3UmaCv6q9LiFXNsu1WbmpiL5g7CTv7GrwHm+CEykfjYe6rI2oES4ieykQPnNX15LGMOj8Ht2r+renSfRNWnOjlrBqrecXXuKxqnSE6ztF3BJ0MqiQVgldaMehFPxr0GVrDHg3gHmJo/aNEnoEFscI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=gafe5F1r; arc=none smtp.client-ip=209.85.166.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Received: by mail-io1-f45.google.com with SMTP id ca18e2360f4ac-7c787eee137so14700939f.0 for ; Thu, 29 Feb 2024 09:45:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1709228741; x=1709833541; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DZQJSc0KZQA8CADa/JynBw1thTIXDFhC1Jy7qGrAIwA=; b=gafe5F1rc0wsJieuqd1ZzAL4cSIGf7I5FRKZU86zr4kQ2r8vjyM7xj/qzkpaSrVLvw Yphw6PpRwjYn3DUVt/F8OatfMEsMWEAGaXsXlHIKZwYk77o/DW6Xx5R7KuBVHZmHtM9e 1iXLztkgOxWaqKzFQXhRUnjYOUMkC+XJJLrwxVW0Ku8QpgCjtAN3Tw/D2igjWwSOYag5 YzJyX5/SceAWqjzuQFTrV8eL8dvvgXZw/1pXZi9ROox2fDYJjCdvw6Wn4i4ZWRQAt/nX 14mXxstWwLcdDMtlhJLcOZ2zGwn7GszzBRh9ksSgx2lg+emV2nZDYXgeNUqKrfCoygbf TFLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709228741; x=1709833541; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DZQJSc0KZQA8CADa/JynBw1thTIXDFhC1Jy7qGrAIwA=; b=JEn5caaH5PQ5x17FtSopTdjbnnztb+nLaPjVw76pNKABpWbasieXtzYlFlxTq7cczx Sze53cZgKtZSD3imbDgYen0lMSDV6irrJda1qg7Q6m7F1D5aNZVeoDzh1ybssI2yeM+V 6pr/pUSeTqLwLCM1WJ5Uv4Uvv7RuU/nI2ugQwYDtyl/IUmGulGO0xNFdysSMx2MxhKS1 rYfO/mISmk2IByLzw6xEzdEA7/3D/rYYGSVsjZuwupKFptI7ieFjCMnEWV9u1NJt3Q++ ew6FFmEaXuU/CRLwTSsH9CbfeRnxKveh4ArtF4slsSAHTknub58J3YrNbiBwZy4Cz749 1URQ== X-Forwarded-Encrypted: i=1; AJvYcCXPLGMy79im6wglVN6eFFeXE91lIXrxlERDnPpLaw83rxvU4KbHyMu/uapNDFT0JtDSv3p99ylNDA4Eg7rCxGj6p1B+L3dX71uBTmts X-Gm-Message-State: AOJu0YwVorxR30W6IFcAM+2ddERdlqSz2sd3DqTckRzrvWGxXZGxfXcA HEXPY+XQnJW/CLmgV8PwVACl7VR21Cy2ewmA9j6T4IhM++7lfTbjH8kb0rrMJO4= X-Received: by 2002:a6b:7d47:0:b0:7c7:f6c0:7fbe with SMTP id d7-20020a6b7d47000000b007c7f6c07fbemr2972329ioq.0.1709228741638; Thu, 29 Feb 2024 09:45:41 -0800 (PST) Received: from [192.168.1.116] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id q13-20020a02c8cd000000b004747d876aefsm416095jao.6.2024.02.29.09.45.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Feb 2024 09:45:41 -0800 (PST) Message-ID: Date: Thu, 29 Feb 2024 10:45:40 -0700 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: [PATCH 2/2] sched/core: split iowait state into two states Content-Language: en-US To: Thomas Gleixner , linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@redhat.com References: <20240228192355.290114-1-axboe@kernel.dk> <20240228192355.290114-3-axboe@kernel.dk> <87zfvj6uub.ffs@tglx> From: Jens Axboe In-Reply-To: <87zfvj6uub.ffs@tglx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 2/29/24 10:31 AM, Thomas Gleixner wrote: > 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 :) I appreciate the commit message police :-) I'll rewrite it. >> +/* >> + * 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? It does, IOWAIT_ACCT always nests inside IOWAIT. I guess it would be more explanatory as: /* * If TASK_IOWAIT isn't set, then TASK_IOWAIT_ACCT cannot have * been set either as it nests inside TASK_IOWAIT. */ if (!(old_wait_flags & TASK_IOWAIT)) current->in_iowait = 0; else if (!(old_wait_flags & TASK_IOWAIT_ACCT)) current->in_iowait_acct = 0; ? -- Jens Axboe