Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp103092iof; Sun, 5 Jun 2022 22:28:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbEYzaDk6PI+Jko61AwoFUIQzyWzyUE91QQk4RUN6nE+bARDatBXulp9zpzcLpiSuNQfMt X-Received: by 2002:a17:902:9006:b0:167:5c8c:4d37 with SMTP id a6-20020a170902900600b001675c8c4d37mr11882266plp.109.1654493284509; Sun, 05 Jun 2022 22:28:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654493284; cv=none; d=google.com; s=arc-20160816; b=LrNzYPqyuFE8UtEMvGMt8gPR5liIUvEmjhPxLGPGhpPtpaE85N1mKXF2CcvF9OHpNO DRRfiI0R/11DRoQXGaEM8xiZTYN6g+qZnuOUjhDLGTH0Bx8Mz1EBMqvdbYSsQfdsCTFw VknZgxU9Rycq+C+aISATTtcHYWGbHXc4m1RD2CEq5hOe0/Wg7/DwSKsyfdZs2DXPH8ku phV4Yr8mvzNX5AOkJhLkJpuoDRtHwWkDlKuj7QktrShpqR/1clX3MrcW/zAzy9Qq8+OU awBjHOwN9oK7sgoeebr79ulqIceOf1E2d8SdyBVWvoW7Vb1lWc4RoGn2LuLKtJskYje7 qmnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=2uuIor8POZMueJirQ23o0QCKviakjo2wCdvxFWX9v9M=; b=oGqBtZLfBKcsd/o3YIHMpB0ILDW7EVxhP4rhjdt3DngBTbbNBGT5012yQy3T2Hj/Hs 4HbpGCY03j9ODxnjDlqyf/BdbHVNxQH1ZB1ySbqw1kZ9j5IDMwHu850BWw197E4PfDsm Og8mUCcoZ5FTLpV+mx7/yotm+VltwgwErVHiFUAsoXqQq1rtBReX57x4xhPnShQi4O/p QN4qJ1kqjdnVVd1mHzEXEwCsdtiuRjq3QLvc9FKk73erMQM9PpNDJ6fQXPzQ4rSx4ZJX YeEhQpM+sd3wJFDjzRFgEwsg6BvwdnC9QL120FHxlgiDsjbv53UGeHvUwtEhZ8LDxaQV QnfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IyBYEfto; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q3-20020a655243000000b003c2828476a9si17041510pgp.641.2022.06.05.22.28.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:28:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IyBYEfto; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3F07D1EBEEE; Sun, 5 Jun 2022 21:29:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347427AbiFCSF7 (ORCPT + 99 others); Fri, 3 Jun 2022 14:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346361AbiFCRvG (ORCPT ); Fri, 3 Jun 2022 13:51:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A101854BFC; Fri, 3 Jun 2022 10:47:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2B4EE604EF; Fri, 3 Jun 2022 17:47:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F8A7C385B8; Fri, 3 Jun 2022 17:47:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278468; bh=NnEyWjMihEvGC1ycsFdaXgQ+EWmAJe/cwgy1WOjErkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IyBYEftoQoio5Z1QwBioYoH6ychr6yVSXGY8SFPwA4FpBep0BSHbrsSB1P41ibZKV IMzmMVzn/ic1E4ixT9fU1TJTTiNvrc8WWn2Vhue3IvkPWPrMTf6hpNeypSI1qGlQnn W4h8OSeW4y9q72n86EBAp7749JbCET1KWnW5ck7M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 5.10 42/53] dm stats: add cond_resched when looping over entries Date: Fri, 3 Jun 2022 19:43:27 +0200 Message-Id: <20220603173819.944245381@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173818.716010877@linuxfoundation.org> References: <20220603173818.716010877@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka commit bfe2b0146c4d0230b68f5c71a64380ff8d361f8b upstream. dm-stats can be used with a very large number of entries (it is only limited by 1/4 of total system memory), so add rescheduling points to the loops that iterate over the entries. Cc: stable@vger.kernel.org Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-stats.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c @@ -224,6 +224,7 @@ void dm_stats_cleanup(struct dm_stats *s atomic_read(&shared->in_flight[READ]), atomic_read(&shared->in_flight[WRITE])); } + cond_resched(); } dm_stat_free(&s->rcu_head); } @@ -313,6 +314,7 @@ static int dm_stats_create(struct dm_sta for (ni = 0; ni < n_entries; ni++) { atomic_set(&s->stat_shared[ni].in_flight[READ], 0); atomic_set(&s->stat_shared[ni].in_flight[WRITE], 0); + cond_resched(); } if (s->n_histogram_entries) { @@ -325,6 +327,7 @@ static int dm_stats_create(struct dm_sta for (ni = 0; ni < n_entries; ni++) { s->stat_shared[ni].tmp.histogram = hi; hi += s->n_histogram_entries + 1; + cond_resched(); } } @@ -345,6 +348,7 @@ static int dm_stats_create(struct dm_sta for (ni = 0; ni < n_entries; ni++) { p[ni].histogram = hi; hi += s->n_histogram_entries + 1; + cond_resched(); } } } @@ -474,6 +478,7 @@ static int dm_stats_list(struct dm_stats } DMEMIT("\n"); } + cond_resched(); } mutex_unlock(&stats->mutex); @@ -750,6 +755,7 @@ static void __dm_stat_clear(struct dm_st local_irq_enable(); } } + cond_resched(); } } @@ -865,6 +871,8 @@ static int dm_stats_print(struct dm_stat if (unlikely(sz + 1 >= maxlen)) goto buffer_overflow; + + cond_resched(); } if (clear)