Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp9214789ioo; Sun, 5 Jun 2022 08:09:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxUpPz6/3gauWG0GANXsQQU84mHQwXTCINUFN7OG8ZR1CthVfbQC0q16j9AxyQ+efO2tdS X-Received: by 2002:a17:906:f158:b0:70a:e1dc:73f4 with SMTP id gw24-20020a170906f15800b0070ae1dc73f4mr15565881ejb.311.1654441789911; Sun, 05 Jun 2022 08:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654441789; cv=none; d=google.com; s=arc-20160816; b=wJX6pIDsyVELucm/Be2pNv57KojZ5SSyKTLOpYd4/yFtWcdVRWcILezbyyhSHxankc Ka4XrgUs0BPJXtNawQJDdFCv8Ec6EtoCn89esSRz0EEWbCANCSVDAdDqm5ywEJGBSFiM ULt1z68XCiX0/0iWvMK2XJtPqNCFCeNVyGMKBypQIgdqs8ObuHPlc4dlYmLacX3bMSa9 g6p4YJgetI566cJqSDEUxk0iPQTLPP2hFboNTV8W3BEBj4uE5CRBuGmW8Dy+/BHaaslh 6XQUEvwuKCMYdEnN7RB84aB+dV0tPuZMLK7f3Y6hlrNl9A9r7dl8CXyuylWmiuQ8DRTA +ZEA== 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=rzJR0WW+Dq1+UsxSrnxgXQdFinfzGLWOg+acCl0vTU4=; b=U+JDQ03v4rnXxDiG4LMj1A4n4IBz26ssudxVSSb5nstrhGJy35KHdbp+QpD0GycNo1 /NmLRIbTBzRV+LZE+as+ODya3xYexAxq5C1ST7FOO3YCtMUE6xEcNhhiURZmYaBGPS8P VSB2dMxUyuWVNTFrGG11l+VAMf3lbtjOAv8KJIGfCV5I1kTS/FGF10et2+KKx3CDZWnj chUsrYg/yxvxAPhWEpsLWaGFX9sLl/PrkC3K0mYZflQ2DKtXZWOwbOzGrQwCTWc8JAw0 5BYja5py1p2VB00h4dhs0MaZ5QODqmk3wRDY7GAHPRIpng+G9gLMiQ3/xgcwba/lfSRN BMRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vmvNuQC4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b14-20020a056402084e00b0042e256e4d71si11200834edz.228.2022.06.05.08.09.25; Sun, 05 Jun 2022 08:09:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vmvNuQC4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344756AbiFCRmg (ORCPT + 99 others); Fri, 3 Jun 2022 13:42:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344644AbiFCRl5 (ORCPT ); Fri, 3 Jun 2022 13:41:57 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C473B54027; Fri, 3 Jun 2022 10:41:22 -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 ams.source.kernel.org (Postfix) with ESMTPS id 1FF99B8242D; Fri, 3 Jun 2022 17:41:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A3C9C385A9; Fri, 3 Jun 2022 17:41:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278079; bh=NtzRiktix8jeRbEZOojHE8GwvkEJds2YxrmN8m2tScc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vmvNuQC4gDi9+68l4Ij59T6cN8T9VEYQg2+nirhtIy7P3adcB01wx+e8b0DblI/NU 92gOR0DPmxhcw40c2p87qdpot1LZEnMuMBQU7oW1IOmvnLbDk5Tqu/9ZzV8GFNt/Rq XTrveGVI0GaM2s0vRM2/NxOv2AyTupivdc8tFgHg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Mike Snitzer Subject: [PATCH 4.14 18/23] dm stats: add cond_resched when looping over entries Date: Fri, 3 Jun 2022 19:39:45 +0200 Message-Id: <20220603173814.915207602@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173814.362515009@linuxfoundation.org> References: <20220603173814.362515009@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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); } @@ -312,6 +313,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) { @@ -324,6 +326,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(); } } @@ -344,6 +347,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(); } } } @@ -473,6 +477,7 @@ static int dm_stats_list(struct dm_stats } DMEMIT("\n"); } + cond_resched(); } mutex_unlock(&stats->mutex); @@ -749,6 +754,7 @@ static void __dm_stat_clear(struct dm_st local_irq_enable(); } } + cond_resched(); } } @@ -864,6 +870,8 @@ static int dm_stats_print(struct dm_stat if (unlikely(sz + 1 >= maxlen)) goto buffer_overflow; + + cond_resched(); } if (clear)