From patchwork Thu Oct 3 13:35:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13821047 Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) (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 5A13E86277 for ; Thu, 3 Oct 2024 13:36:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727962616; cv=none; b=JN6ratbR0snoxtPGWTlmMx0bN/A8Qv5uXuZ1tmdt38fT9VMU8FY8em+H/b3R5l3DhC+oxnn4V133CSYhVKefrhAc48wRPGJFngG+X8GyyLLv3y+C+Ie+5Q2Tdu43ewhmBYIr17F/R6nqIgFyftF/eipnoDWFEcNe45GFyiSJPjk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727962616; c=relaxed/simple; bh=RZSOVPlhbcDsE0eC/0+ARl+Y4zL4GleNla8AyPtn2Zk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DTVmolU06PjSqXeAGX+keFxLWx8V+/5zaObUJ99o+Qf7QZICnmTgrhRT7HJo53vwHvRLUmWjYfhwoH1lg2PNJzVCqUJ7E2FdL5Z0vNmHtXXWa7OMUehpbmrkvF472a8ymA3+hYqtobk18CFM1Q+POai20MSPNxUNzn9bgB2GyCs= 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=DTBAmwSp; arc=none smtp.client-ip=209.85.166.52 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 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="DTBAmwSp" Received: by mail-io1-f52.google.com with SMTP id ca18e2360f4ac-82cdb749598so48258839f.1 for ; Thu, 03 Oct 2024 06:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1727962611; x=1728567411; 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=fQNQQf3nV4sV7k40ZpaubDkS0LPWbRyCMa+MHVBW8jU=; b=DTBAmwSpftj57vuuytmjxJfA1nS14y1O78f5F93eOI86Sv2k6FU5waWoEpdyt6v+tO mpDIgq+V1xNfrwYh6leE11UwzRMXvFav32mXRq+Tg+aMjhXu5M6V9V5/9fJ4ryGjBALU EtEJSmhtunAWVJA7biXJQew5RUwg569JZmiyTU88MdwSi3cdBE//WjqwdIRPsLfCQ8wb sEmregdYUiNkHykPbMkn625JYjljm50SoFzLTjJ4WiW/9wNI0lPcrBqW9iDzHIw7kG7N YJ9/NUgZxCky/udekFouq/mY/r229dKnHepQ0mzmRk51hXtFg7ska411SeaoqDpIzDqT a2WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727962611; x=1728567411; 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=fQNQQf3nV4sV7k40ZpaubDkS0LPWbRyCMa+MHVBW8jU=; b=ifi6vG7d1J05O5uOpftJKPE85JhKn0QtBUF2nPTOqswD0xStS9Le2UboZaFmqr/y9c 1O7EzlSQg05kGi2yidNhUkiuZvGS1dOCBwWpLJ7kYmppyp+ocGq+i2W5m/W4ffBXvu+A UwNVNiR1iVRGtsK+7O5DAx5EUvKujF6r3c+luzUYjdUYGJiGgbOUYetEX/PnTOKtSvyp 19xhJYPQn7jMH7H1qs76cgXGC/q7HtBd+Ax6teaVNnNTCB7eu6OcAoxt8Xty6ACONqYO XDSzrPfNIwfMyNY+Fm1V8uflNYawPWNszdTKj1Ly51hXaIuYbOGip7hdgFDaH0MSwBCR F7Yg== X-Gm-Message-State: AOJu0YwAWx5gd5VrsetYCJt4esO5Hi78XqOqni64nCYg2BO6poARgX99 kavvU9bW6YWLmT9TyocjJFavXj51bLYBdWe3caS0OGM7XOoyI/Fp8h9uAaXh5+6idOBa8inyR9C ldq0dfg== X-Google-Smtp-Source: AGHT+IHQjvZJKw2jk+qfOzNmd7TiUDLjKJcED2fmVz1xCj4xa6IcopdsqjuVJibikMH7jzlSM4B1kg== X-Received: by 2002:a05:6602:1509:b0:82c:bdec:1c0e with SMTP id ca18e2360f4ac-834d83b644cmr622256139f.2.1727962610853; Thu, 03 Oct 2024 06:36:50 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4db55a63fd5sm274128173.100.2024.10.03.06.36.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 06:36:50 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 1/2] block: remove 'req->part' check for stats accounting Date: Thu, 3 Oct 2024 07:35:32 -0600 Message-ID: <20241003133646.167231-2-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003133646.167231-1-axboe@kernel.dk> References: <20241003133646.167231-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If RQF_IO_STAT is set, then accounting is enabled. There's no need to further gate this on req->part being set or not, RQF_IO_STAT should never be set if accounting is not being done for this request. Signed-off-by: Jens Axboe Reviewed-by: Christoph Hellwig --- block/blk-mq.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index ee6cde39e52b..f21bd390e07b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -92,7 +92,7 @@ static bool blk_mq_check_inflight(struct request *rq, void *priv) { struct mq_inflight *mi = priv; - if (rq->part && blk_do_io_stat(rq) && + if (blk_do_io_stat(rq) && (!bdev_is_partition(mi->part) || rq->part == mi->part) && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) mi->inflight[rq_data_dir(rq)]++; @@ -762,7 +762,7 @@ EXPORT_SYMBOL(blk_dump_rq_flags); static void blk_account_io_completion(struct request *req, unsigned int bytes) { - if (req->part && blk_do_io_stat(req)) { + if (blk_do_io_stat(req)) { const int sgrp = op_stat_group(req_op(req)); part_stat_lock(); @@ -980,8 +980,7 @@ static inline void blk_account_io_done(struct request *req, u64 now) * normal IO on queueing nor completion. Accounting the * containing request is enough. */ - if (blk_do_io_stat(req) && req->part && - !(req->rq_flags & RQF_FLUSH_SEQ)) { + if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) { const int sgrp = op_stat_group(req_op(req)); part_stat_lock(); From patchwork Thu Oct 3 13:35:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 13821048 Received: from mail-io1-f42.google.com (mail-io1-f42.google.com [209.85.166.42]) (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 B5F2519B3ED for ; Thu, 3 Oct 2024 13:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727962616; cv=none; b=f6tjQXkjCm4csVYrML+dEiAjoJu2xbP3aT+5ThPDLVk0jT0lW1AuAhTY5AJSjbDM4rAi1+XP8k5zjygla3BRrfgdLU8mew0pYqyM4gKm9d6OmTJ7Te8Y5hRtvASqyd8DTxiKFCfmdscUM6OHZ2fVxMLhJa2u2ybmdDzdMYLWg0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727962616; c=relaxed/simple; bh=gqGk1l0IgEUvuszEn2vhaOjtZw/YxyiYXk0N4msjj10=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eUnvI9jTuyBAhi6jV6Z9Qn0gJWm9sVGsKHLZhESK4lK0iOrmTLwyeKDIFREdupvvnz9UQBx9CA+7HOpTv7cSOI89tA61TRYjzdaJZAPgjpQNtJ4HnWvUJdBGbfLvcrJWZzqfNWBfShl0oLnMvyMaTniPLS9AFVkNv8Bs2Fx3BPA= 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=FFtN9oeh; arc=none smtp.client-ip=209.85.166.42 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 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="FFtN9oeh" Received: by mail-io1-f42.google.com with SMTP id ca18e2360f4ac-82cd869453eso39354339f.0 for ; Thu, 03 Oct 2024 06:36:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1727962613; x=1728567413; 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=GMdIJC4NqrLb7Lo66MHixxVJSZ8GKxe604OIz/xFcLg=; b=FFtN9oeh5PGQpbbL5bto2I1WD/bSAql6Hk1vP3odWoDcVLQdksyn1f9VbPutgQ/yLG y52Wz0rqT2GUFSpyt2dtD4KacaJH0NFK0ua6o6sxU+pZ2j+N/DVLwIKpQC+JtO3yFwLQ BdSZl49Ir+9MRSgt7xWO2ZfXx1jx49Lvdl9TOVZYyQfZUENbNpBPB1Zlc3bUisUXsuUL wR44/rZzLf8lZ38QC5Fa5aVlB1T5Uj0u/PSGSjTilUiMDOAjNvF8WtN53rymVZgScrgH khKmtR/QggiIght/+Jf8M9espYcMZ/bbHe+jT2vylUlPsOHrWp5K0xAg+Md7r9hKJKKT hw1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727962613; x=1728567413; 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=GMdIJC4NqrLb7Lo66MHixxVJSZ8GKxe604OIz/xFcLg=; b=BslLaRIv//WcnmLvrQriJ5tdPz0OhfztXsRr8c2d4Jefl2PIpNlmYS4IEjgMDAwEp/ evtrURHRhNtAY1zc/0DoFZdtgmS9OfaVjT3jRv4WobotDCfxbIyNjlkOBVeYORUcFNY/ Nw7SUz90Kxla3aRrZGpgDj3zQix0vIe5WgUCFcIQSoXoMbnX86nQWUr4/iFH5Wt/4O4F Oq4oG+wpXA4nlWdMqz+2a50TAlG/7tohY3ZBOwe+qxG+mhazNtDwbwhF8r3PAh1sIiPn J5RmjRHEfUWLoMm8sknQTsOz6JvZcFKVXm1fn7l+RUGHxFsl61vNMYxnYRooS8nULV2q shmw== X-Gm-Message-State: AOJu0YxsvA1rgMRcBvhfMKiTZQyGcTZZfQGEA9Ef1y7xZZ6aEu80ypWT pWUau+ftWJXTV52IAH1xdKM1JHkz/s5j9uaXUSf6E6yjxkuEwPnsxMIxEHLYgl/thZCiUeqx+4G zMPQN9A== X-Google-Smtp-Source: AGHT+IEV/o1XiT42T3ODR2wQbYCxXkpHJVSrYqE4coV5x8wF44SboIY3DUCuogebppNDfDri4iUCDg== X-Received: by 2002:a05:6e02:b2f:b0:3a0:9c99:32d6 with SMTP id e9e14a558f8ab-3a365954820mr56241175ab.24.1727962613189; Thu, 03 Oct 2024 06:36:53 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4db55a63fd5sm274128173.100.2024.10.03.06.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 06:36:51 -0700 (PDT) From: Jens Axboe To: linux-block@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 2/2] block: kill blk_do_io_stat() helper Date: Thu, 3 Oct 2024 07:35:33 -0600 Message-ID: <20241003133646.167231-3-axboe@kernel.dk> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241003133646.167231-1-axboe@kernel.dk> References: <20241003133646.167231-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 It's now just checking whether or not RQF_IO_STAT is set, so let's get rid of it and just open-code the specific flag that is being checked. Signed-off-by: Jens Axboe Reviewed-by: Christoph Hellwig --- block/blk-merge.c | 13 ++++++------- block/blk-mq.c | 6 +++--- block/blk.h | 11 ----------- 3 files changed, 9 insertions(+), 21 deletions(-) diff --git a/block/blk-merge.c b/block/blk-merge.c index ad763ec313b6..8b9a9646aed8 100644 --- a/block/blk-merge.c +++ b/block/blk-merge.c @@ -797,7 +797,7 @@ static inline void blk_update_mixed_merge(struct request *req, static void blk_account_io_merge_request(struct request *req) { - if (blk_do_io_stat(req)) { + if (req->rq_flags & RQF_IO_STAT) { part_stat_lock(); part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); part_stat_local_dec(req->part, @@ -1005,12 +1005,11 @@ enum elv_merge blk_try_merge(struct request *rq, struct bio *bio) static void blk_account_io_merge_bio(struct request *req) { - if (!blk_do_io_stat(req)) - return; - - part_stat_lock(); - part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); - part_stat_unlock(); + if (req->rq_flags & RQF_IO_STAT) { + part_stat_lock(); + part_stat_inc(req->part, merges[op_stat_group(req_op(req))]); + part_stat_unlock(); + } } enum bio_merge_status bio_attempt_back_merge(struct request *req, diff --git a/block/blk-mq.c b/block/blk-mq.c index f21bd390e07b..8e75e3471ea5 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -92,7 +92,7 @@ static bool blk_mq_check_inflight(struct request *rq, void *priv) { struct mq_inflight *mi = priv; - if (blk_do_io_stat(rq) && + if (rq->rq_flags & RQF_IO_STAT && (!bdev_is_partition(mi->part) || rq->part == mi->part) && blk_mq_rq_state(rq) == MQ_RQ_IN_FLIGHT) mi->inflight[rq_data_dir(rq)]++; @@ -762,7 +762,7 @@ EXPORT_SYMBOL(blk_dump_rq_flags); static void blk_account_io_completion(struct request *req, unsigned int bytes) { - if (blk_do_io_stat(req)) { + if (req->rq_flags & RQF_IO_STAT) { const int sgrp = op_stat_group(req_op(req)); part_stat_lock(); @@ -980,7 +980,7 @@ static inline void blk_account_io_done(struct request *req, u64 now) * normal IO on queueing nor completion. Accounting the * containing request is enough. */ - if (blk_do_io_stat(req) && !(req->rq_flags & RQF_FLUSH_SEQ)) { + if ((req->rq_flags & (RQF_IO_STAT|RQF_FLUSH_SEQ)) == RQF_IO_STAT) { const int sgrp = op_stat_group(req_op(req)); part_stat_lock(); diff --git a/block/blk.h b/block/blk.h index 84178e535533..ea926d685e92 100644 --- a/block/blk.h +++ b/block/blk.h @@ -405,17 +405,6 @@ void blk_apply_bdi_limits(struct backing_dev_info *bdi, struct queue_limits *lim); int blk_dev_init(void); -/* - * Contribute to IO statistics IFF: - * - * a) it's attached to a gendisk, and - * b) the queue had IO stats enabled when this request was started - */ -static inline bool blk_do_io_stat(struct request *rq) -{ - return rq->rq_flags & RQF_IO_STAT; -} - void update_io_ticks(struct block_device *part, unsigned long now, bool end); unsigned int part_in_flight(struct block_device *part);