Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp87687iof; Sun, 5 Jun 2022 21:59:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx69L76SjBFompA88N5aGipR6y6Bh9K2EWkcVVtwradY7Qonz4uNScrRs0XxnNtroj51QO6 X-Received: by 2002:a63:f455:0:b0:3fc:e1c1:bf10 with SMTP id p21-20020a63f455000000b003fce1c1bf10mr18187748pgk.467.1654491579598; Sun, 05 Jun 2022 21:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654491579; cv=none; d=google.com; s=arc-20160816; b=CiQKlPrvih7srJOx3nz6D8c5hjg+1GrXFAIhkvdXdDc2hRYDE1RfPt2P5+IA6437l8 e9D711ht9CaHquUYLQSy2PnnjpZBVVmrqfvglD3Em93JEhDYtBG62/1SrK8eSEjT9SG2 aw1+YKL0vVhJPH725yE01+N1nmt2pQD+PDzNogFII1rBl0AJZoBDYj/+DLj3YUF3fu8C 8MkAGSy0tXc+joVHE3ZWbS6eMJlhh0IyoAZ9mwgQRc+bXcIqcMYwdhhKBHYa74/Mfadq AijaJlaidJYHg2WY2ZbdR2l6/ApAkA2zaxVfRW42Jq9ajEOL7q+Zc/CGl+2tqnKZ7sPx gmBQ== 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=0y+9qlRWb9XTf7drus5DSGJpMSHpqDNazZYxNoHEnCZgqMTGjMJgLrkk1CT9JdX+aM aS3VckDnKsPJ1BF+t1xAkcB3OjmIb/DxSEjxxweSgg+n/V6RnHAzGNb/fWRkZirbAxZd oIvcSbCrNj1GvY1pkbzYbE90YpuifVFOgyzGTqQUKQTbyofGS72QrTceZDemJrobGY7T X9dAt16Cd0kbpJ7uQMAFcNBNwCzwhn6j/RIkfuLtErweXymZHXrzr/pjQu8JAhg/K66S MeR6LS2S7wLCJvG/Cp12LyXG0RBxWkYyq1r8xEnRZtpmtFieFzrZlmXmACCvYwfXVyLp r9Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mSUZdAoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id 19-20020a631753000000b003f9f41da8casi19965817pgx.14.2022.06.05.21.59.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:59:39 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mSUZdAoP; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 5E39378EEB; Sun, 5 Jun 2022 21:13:18 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345251AbiFCRtE (ORCPT + 99 others); Fri, 3 Jun 2022 13:49:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345368AbiFCRsN (ORCPT ); Fri, 3 Jun 2022 13:48:13 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E821B5418F; Fri, 3 Jun 2022 10:45:10 -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 859E660A0F; Fri, 3 Jun 2022 17:45:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E10DC385B8; Fri, 3 Jun 2022 17:45:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278310; bh=NnEyWjMihEvGC1ycsFdaXgQ+EWmAJe/cwgy1WOjErkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSUZdAoPym97KU2ubp9gK3epjmL9A90oRf7BVhKakGAsuDq/hOQPnVxqeoq95pumc puPQSl7VJC4KkMcrehfb3gGYhInEPiFvnXok9l7cDTa1cAusKKbl9z3BTQD/7Mj1n6 KRXaPbaSnvd8kcKY0+zmqqeduT9y7lWK3zLmNa4w= 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.4 25/34] dm stats: add cond_resched when looping over entries Date: Fri, 3 Jun 2022 19:43:21 +0200 Message-Id: <20220603173816.915846548@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.990072516@linuxfoundation.org> References: <20220603173815.990072516@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)