Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp2017771lqp; Tue, 16 Apr 2024 05:16:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5VKtSGCL+/dTx8O6zCh3QEWeNb7O//jjqJVJYMBJ9QNswbSfX5a9RGb7C+5hTIbYVHyJDITWrB1VUjOYbtto/dwqvr3+v3/SwT+YmqQ== X-Google-Smtp-Source: AGHT+IE3IbOCSZ1I19azNfmomNHCodslRyRzA0EOlnjUmFZNUoxtndGZ2j6/oLYt7j3f7y7vUJwc X-Received: by 2002:a05:6a20:1059:b0:1a9:5bb1:ba27 with SMTP id gt25-20020a056a20105900b001a95bb1ba27mr11032442pzc.9.1713269812336; Tue, 16 Apr 2024 05:16:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713269812; cv=pass; d=google.com; s=arc-20160816; b=v++HeYCCT5jARs65KTbKaq/dc52KR0Lv0NB9gYSiVwtu/HPHzn2phTmXt8kKjnkfll L07a2PzoQ2NuuvPDP/cgtaW1bVwEhSNikKwnoEY3+EwxzGuUjdyx2Y9NDr8bLaNV7Laz 6Jk5L2pJHMlndKtoq+mwLjJ3gLmtSPQyFmUpXQQV8WlFdGEnwnfzTKfdFJWvTLmh5lrR 6clTEeVleapl+aQsraXeyzsF7KMgSUhll07Z0pOj72mLVAnys7bONpuhc63hHavV/mch do5SfGVYsYWMhGWRh6w9raxsG+eEfA9fhB9KlOas+365Z989YHTPsNpfisRh1SyjbyAo +IXQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=M8FZtLez5NK90qpzb7pJiE/cmJLi/g0rDQRNg4yxT3c=; fh=eDxpG5bT59QkvYs1FM0EoP/fOyleWVXt1wvOiWFp3w8=; b=ridU7yt2tD1MjA1rghDBrMYDyV4OAGKLrVoD0B02ryy1ZojFw4hJ6MPrN6dvj9gbm/ aJuz7L2DkorH01ekzHb2+1LMP6SLbFgVurNXUVAf7PqOs5cM15Nvnu6N6NNgAGxUpnp3 fchY0iAiFQK5GMgwpM3/DBPdwlcU1KikzGB7Y10JiLEHASwOWRdF8glKhkpnbU2JUTu/ Zw+HsoZXIp17RQiYINcpIWbxskPiIAkV29c97W5cVd8tvYS8plFoEObRYqqYqG1a/1jT K0AO+6OouCakVgJLASSmKHbx4gt4BLZm8rnAN0L3/gQSmyMRrH0GbLtbdHO4vhb0o/Aq AkZw==; 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=AkAkzVLp; 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-146763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146763-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i11-20020a63e44b000000b005f07f356d1asi9337671pgk.716.2024.04.16.05.16.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 05:16:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-146763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=AkAkzVLp; 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-146763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-146763-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A0ADCB21B21 for ; Tue, 16 Apr 2024 12:16:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61E2512C460; Tue, 16 Apr 2024 12:15:40 +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="AkAkzVLp" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 610C312AAE2 for ; Tue, 16 Apr 2024 12:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713269739; cv=none; b=I8/ZjHI77c2Lh/2mRwX42F9OKy/SZ8mm1K9m7xX9wmfWABEw04c9QVNMFpzrZzMqjkjWq5Q/GbGXFRoyo8el6E03xLVN1WqCm720T0UVxQHoh1qzZjs53SsSn+IN8m/8EFdl3k6WwWFqxVYKiBb1r+vNly7PXLPITcayndBwCrk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713269739; c=relaxed/simple; bh=LFTwl+KaNR01xUhsIjDuW6dm42jh/bpLqCuATv5koSk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I0BXcjcNwmP96KuJei/da57Fo890Au135qVqxcTKdpui1lVcR0oUD6nmBaCl0+3e5MXq6H5u5DMj+37Sna2433It3t/fQPbZxcKqWLqMouWVNgA+9vHY0BOwqhxw60GIUYrwjySL0rnWmefeAtnBtejMBMQt8KLXIwww88Eq4uI= 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=AkAkzVLp; arc=none smtp.client-ip=209.85.210.174 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-pf1-f174.google.com with SMTP id d2e1a72fcca58-6f013c304bbso377151b3a.1 for ; Tue, 16 Apr 2024 05:15:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1713269736; x=1713874536; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=M8FZtLez5NK90qpzb7pJiE/cmJLi/g0rDQRNg4yxT3c=; b=AkAkzVLpXD7vhIZlLh9bC9VAHIHGZf5OSN8xvZhdYjiuYE5WWs0OEv9ZnbKASq7+dp aUA/u0VxKpJBUMOnbVPVtVsikuTPc4VVd+v7I6lr77Mxz8C2Dn5X7AgNRxGS08ivFNbB ubOSIG2Fg0d3gHblVS5WwMUqTvbA5qJBDUSwexlVlWWhSKzcnGH21OGx90RAM7QwM6Do W0cVAkM/EhAMT9BaCB9cjUFhD/bh3NloKvTNBSwBWPxPTkxFKSh1xM/9Q3uKMzGkLmlj nRc8o8Z5QNbqLbCDPrMehe38mpqKU8WuVlSyCSBae/WgRo6cBpS+Weos0KbUdBJEAOwo uA/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713269736; x=1713874536; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=M8FZtLez5NK90qpzb7pJiE/cmJLi/g0rDQRNg4yxT3c=; b=n4iFyByZYn3GmIrVpjrr18LjWVXv1e6liAb0rg0uxjJUJlYuQsEQnsQKsT9vmIu9vp h5mojnGXN7/zOqTNuP2PoJwubOQ2u+c0A+qyMI+eP/o7PzIgoRe7xJ5DGjZdo8jSLQ0h zYztH4mq7ONyH0u7sPkKqL9QzCaR6NxSEOdR6BbgciR7hiUDQqF7lWjLf0mFDs43hO9I rfHj8i+If30wKLMGH6HbGD8UsWwHHmcIS6hHAsZSR7z8PHIe4xfNuZ4/yD3Qq07B3dlV qXZQCein4kPHA2XUL7NCyMecWFSbRgArkRFqnDbdIL2Vso/l21FNktxKdLXgx219ilDc 0jaA== X-Gm-Message-State: AOJu0Yy6dTjMlAWYkn6w8sfbU5VvVei9b7MrwFATTckM87vN1sQVQl0N WjqT5o54WTMz2hntZ3JStkHFaAlgBVou+dWi+JuOpYihAx6Y6tKnKviPLREo+j4RoMWQccKS/bc o X-Received: by 2002:a17:902:ce8d:b0:1e4:344e:768e with SMTP id f13-20020a170902ce8d00b001e4344e768emr15013803plg.5.1713269736213; Tue, 16 Apr 2024 05:15:36 -0700 (PDT) Received: from localhost.localdomain ([198.8.77.194]) by smtp.gmail.com with ESMTPSA id d12-20020a170903230c00b001e43576a7a1sm9584693plh.222.2024.04.16.05.15.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 05:15:34 -0700 (PDT) From: Jens Axboe To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, tglx@linutronix.de, Jens Axboe Subject: [PATCH 2/4] sched/core: change rq->nr_iowait type to atomic_long_t on 64-bit Date: Tue, 16 Apr 2024 06:11:19 -0600 Message-ID: <20240416121526.67022-3-axboe@kernel.dk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240416121526.67022-1-axboe@kernel.dk> References: <20240416121526.67022-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit In preparation for storing two separate iowait states in there, bump the size from a 32-bit to a 64-bit size, for 64-bit kernels. Note that on 32-bit, the number of tasks are limited to 0x8000, which fits just fine in even half of the existiing 32-bit atomic_t. For 64-bit, no such limit exists, hence play it safe and make it a 64-bit atomic. Signed-off-by: Jens Axboe --- kernel/sched/core.c | 14 +++++++++++++- kernel/sched/sched.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 977bb08a33d2..6a6c985220b1 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3723,17 +3723,29 @@ static inline cpumask_t *alloc_user_cpus_ptr(int node) static void task_iowait_inc(struct task_struct *p) { +#ifdef CONFIG_64BIT + atomic_long_inc(&task_rq(p)->nr_iowait); +#else atomic_inc(&task_rq(p)->nr_iowait); +#endif } static void task_iowait_dec(struct task_struct *p) { +#ifdef CONFIG_64BIT + atomic_long_dec(&task_rq(p)->nr_iowait); +#else atomic_dec(&task_rq(p)->nr_iowait); +#endif } int rq_iowait(struct rq *rq) { +#ifdef CONFIG_64BIT + return atomic_long_read(&rq->nr_iowait); +#else return atomic_read(&rq->nr_iowait); +#endif } static void @@ -10065,7 +10077,7 @@ void __init sched_init(void) #endif #endif /* CONFIG_SMP */ hrtick_rq_init(rq); - atomic_set(&rq->nr_iowait, 0); + atomic_long_set(&rq->nr_iowait, 0); #ifdef CONFIG_SCHED_CORE rq->core = rq; diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 387f67ddf18a..c2802d066615 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1049,7 +1049,11 @@ struct rq { u64 clock_idle_copy; #endif +#ifdef CONFIG_64BIT + atomic_long_t nr_iowait; +#else atomic_t nr_iowait; +#endif #ifdef CONFIG_SCHED_DEBUG u64 last_seen_need_resched_ns; -- 2.43.0