Received: by 2002:a05:7208:13ce:b0:7f:395a:35b6 with SMTP id r14csp608355rbe; Thu, 29 Feb 2024 08:39:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXEAHxDhW+e86n78qfIJWcWOKWmstp4sdLS71jeCJnt5wDySqt6JBY/Ptmc7Ylwz9bJ+pFsC5Cm7GAwxUd+8DH9mt1XKDWENzqY+9WBig== X-Google-Smtp-Source: AGHT+IGMjAtDh7c2tsWcZ+Z6ok1IiAeEGfER84DBIsI3SKCvzLqEaPE9W9DiLYQd4ImML7MyBQ6K X-Received: by 2002:ac8:5f81:0:b0:42e:c14d:59cd with SMTP id j1-20020ac85f81000000b0042ec14d59cdmr1742449qta.12.1709224797743; Thu, 29 Feb 2024 08:39:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709224797; cv=pass; d=google.com; s=arc-20160816; b=C7bHZQBcjx+l/ACgyt10sypbIjgXt7PoE6DcItY4+hZTk80RFvyTuBu9ZCpqj5iBfT frK/ohEhgWs2ZL6crBWF0mpZZp8VGf4sh9y7zAb/ZGw2606rzoEXyTy1rAnhkI/jC0iJ O2XEn6TguMaMCdozr902yfm5bekng1d/jOR++Ou7bqYFbL9d5iS0cRSw6z8UqIf3z9GL +PmRUwHenGqrFyqSqC0SlXiQq2K+nJ5uexYNUgsX5bvGws3k6+egm2lb36pIFtU+Mjqd bJv3SpLf+cpVb2RX1+jhP7Hx2VfORR/BTX85eCu3zphTWL2YfjtVNwtAy2DWdHDfc6du RIWQ== 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; bh=W9oFuZM18iePxoNhoUZd42tc8EBpPi2h9b0i6gnLX1k=; fh=7n8c8G9rAEFrlWsBSsV48mjsTf4d+ahzLd31HvzmNyY=; b=bW1tbcu0x0TMuMaQUp5vPQAnIO1fnn/Kw7wBN0oCITrQamDeomaFWZ3k50puY8lfWa 8gv/UhH0qWNktgmCW82BjyDH79pgJYQ7gk6OyUEUyRE+6YsaBLfc92G2An353jkwuF/l /tiZNTwh0xlHkR02OXu86+LryRMQRTMBhQaSStKpqiLWc7kzrD+mvhyjHz84ubltVHxf S7Su30DWRvzzunAkCFi3rFWllXt3k119mcPsyeDpUviSHZPT05a/7kO9xDLLvfA3yMO5 THcgQXp18QOmohawP5IauDkcMtnKGkdlo+sLvLBfaB8tFkddiX8XF+zZTFO7//2aNCAi Yz4Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=molgen.mpg.de); spf=pass (google.com: domain of linux-kernel+bounces-87095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87095-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ay22-20020a05622a229600b0042db60cb428si1752424qtb.576.2024.02.29.08.39.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 08:39:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87095-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; arc=pass (i=1 spf=pass spfdomain=molgen.mpg.de); spf=pass (google.com: domain of linux-kernel+bounces-87095-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87095-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 76BB21C210B6 for ; Thu, 29 Feb 2024 16:39:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C70172E410; Thu, 29 Feb 2024 16:39:49 +0000 (UTC) Received: from mx3.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) (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 6B7A4160645; Thu, 29 Feb 2024 16:39:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=141.14.17.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709224789; cv=none; b=CH1emQcYnN/IqTCxB4VG6I5Oax7Gt1+biT9SuD2vkKc/QctvpL9QQRJlSdW1LkCG0SEeAbAA/T7SJD1Zmsrzq4ePDmQyt2poPkWsEDaHvdIcloaX0Lz58O2zLThVk7wRZC//+Y2mMMdDA5t2U0fUfKwV3yOqjnGpFJ4r1pi5MWU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709224789; c=relaxed/simple; bh=I2nNf4c0LRphhHr1U1aLklikvtNXhwBKV22E+huo1rg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=LZiHic8kHIE7aQg7wbivIt7db+P3ubhbxDunnLScvzL9XlCeYXN/oY2KM9rJyZsVu3S2rwTKkdij9xl+vGXqWT58gvuwvDe+H3Iw8+YOC5UGNBeiyQ1wdKLTi0n0+ZDiNfbVrKbb2xMW/9yzMR2fA/UhQEMaUTJfwUeg+k58KMA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=molgen.mpg.de; spf=pass smtp.mailfrom=molgen.mpg.de; arc=none smtp.client-ip=141.14.17.11 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=molgen.mpg.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=molgen.mpg.de Received: from [192.168.0.53] (ip5f5aeddf.dynamic.kabel-deutschland.de [95.90.237.223]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 2EB1E61E5FE04; Thu, 29 Feb 2024 17:37:03 +0100 (CET) Message-ID: <7b030433-518e-4fe7-976c-3ffb5f7f1a85@molgen.mpg.de> Date: Thu, 29 Feb 2024 17:37:01 +0100 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 md-6.9 v4 03/11] md/raid1: record nonrot rdevs while adding/removing rdevs to conf Content-Language: en-US To: Yu Kuai Cc: xni@redhat.com, paul.e.luse@linux.intel.com, song@kernel.org, neilb@suse.com, shli@fb.com, linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, yangerkun@huawei.com References: <20240229095714.926789-1-yukuai1@huaweicloud.com> <20240229095714.926789-4-yukuai1@huaweicloud.com> From: Paul Menzel In-Reply-To: <20240229095714.926789-4-yukuai1@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Dear Yu, Thank you for your patch. Am 29.02.24 um 10:57 schrieb Yu Kuai: > From: Yu Kuai > > For raid1, each read will iterate all the rdevs from conf and check if > any rdev is non-rotational, then choose rdev with minimal IO inflight > if so, or rdev with closest distance otherwise. > > Disk nonrot info can be changed through sysfs entry: > > /sys/block/[disk_name]/queue/rotational > > However, consider that this should only be used for testing, and user > really shouldn't do this in real life. Record the number of non-rotational > disks in conf, to avoid checking each rdev in IO fast path and simplify The comma is not needed. > read_balance() a little bit. Just to make sure, I understood correctly. Changing `/sys/block/[disk_name]/queue/rotational` will now not be considered anymore, right? For the summary, maybe you could also say “cache”. Maybe: Cache attribute rotational while adding/removing rdevs to conf > Co-developed-by: Paul Luse > Signed-off-by: Paul Luse > Signed-off-by: Yu Kuai > --- > drivers/md/md.h | 1 + > drivers/md/raid1.c | 17 ++++++++++------- > drivers/md/raid1.h | 1 + > 3 files changed, 12 insertions(+), 7 deletions(-) > > diff --git a/drivers/md/md.h b/drivers/md/md.h > index a49ab04ab707..b2076a165c10 100644 > --- a/drivers/md/md.h > +++ b/drivers/md/md.h > @@ -207,6 +207,7 @@ enum flag_bits { > * check if there is collision between raid1 > * serial bios. > */ > + Nonrot, /* non-rotational device (SSD) */ > }; > > static inline int is_badblock(struct md_rdev *rdev, sector_t s, int sectors, > diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c > index 6ec9998f6257..de6ea87d4d24 100644 > --- a/drivers/md/raid1.c > +++ b/drivers/md/raid1.c > @@ -599,7 +599,6 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > int sectors; > int best_good_sectors; > int best_disk, best_dist_disk, best_pending_disk; > - int has_nonrot_disk; > int disk; > sector_t best_dist; > unsigned int min_pending; > @@ -620,7 +619,6 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > best_pending_disk = -1; > min_pending = UINT_MAX; > best_good_sectors = 0; > - has_nonrot_disk = 0; > choose_next_idle = 0; > clear_bit(R1BIO_FailFast, &r1_bio->state); > > @@ -637,7 +635,6 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > sector_t first_bad; > int bad_sectors; > unsigned int pending; > - bool nonrot; > > rdev = conf->mirrors[disk].rdev; > if (r1_bio->bios[disk] == IO_BLOCKED > @@ -703,8 +700,6 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > /* At least two disks to choose from so failfast is OK */ > set_bit(R1BIO_FailFast, &r1_bio->state); > > - nonrot = bdev_nonrot(rdev->bdev); > - has_nonrot_disk |= nonrot; > pending = atomic_read(&rdev->nr_pending); > dist = abs(this_sector - conf->mirrors[disk].head_position); > if (choose_first) { > @@ -731,7 +726,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > * small, but not a big deal since when the second disk > * starts IO, the first disk is likely still busy. > */ > - if (nonrot && opt_iosize > 0 && > + if (test_bit(Nonrot, &rdev->flags) && opt_iosize > 0 && > mirror->seq_start != MaxSector && > mirror->next_seq_sect > opt_iosize && > mirror->next_seq_sect - opt_iosize >= > @@ -763,7 +758,7 @@ static int read_balance(struct r1conf *conf, struct r1bio *r1_bio, int *max_sect > * mixed ratation/non-rotational disks depending on workload. > */ > if (best_disk == -1) { > - if (has_nonrot_disk || min_pending == 0) > + if (READ_ONCE(conf->nonrot_disks) || min_pending == 0) > best_disk = best_pending_disk; > else > best_disk = best_dist_disk; > @@ -1768,6 +1763,11 @@ static bool raid1_add_conf(struct r1conf *conf, struct md_rdev *rdev, int disk, > if (info->rdev) > return false; > > + if (bdev_nonrot(rdev->bdev)) { > + set_bit(Nonrot, &rdev->flags); > + WRITE_ONCE(conf->nonrot_disks, conf->nonrot_disks + 1); > + } > + > rdev->raid_disk = disk; > info->head_position = 0; > info->seq_start = MaxSector; > @@ -1791,6 +1791,9 @@ static bool raid1_remove_conf(struct r1conf *conf, int disk) > rdev->mddev->degraded < conf->raid_disks) > return false; > > + if (test_and_clear_bit(Nonrot, &rdev->flags)) > + WRITE_ONCE(conf->nonrot_disks, conf->nonrot_disks - 1); > + > WRITE_ONCE(info->rdev, NULL); > return true; > } > diff --git a/drivers/md/raid1.h b/drivers/md/raid1.h > index 14d4211a123a..5300cbaa58a4 100644 > --- a/drivers/md/raid1.h > +++ b/drivers/md/raid1.h > @@ -71,6 +71,7 @@ struct r1conf { > * allow for replacements. > */ > int raid_disks; > + int nonrot_disks; > > spinlock_t device_lock; > As you meant “fastpath” in the commit message, if I remember correctly, this does not improve the performance in benchmarks, right? Kind regards, Paul