Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp72926iof; Sun, 5 Jun 2022 21:30:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzkxWmLoz5rS8TMku2cpffaYhB7G0ZiWMc1fJXOjNUY/j2Hvr2sZOguJaJlTftSyVpSO2p0 X-Received: by 2002:a17:903:31d1:b0:159:804:e852 with SMTP id v17-20020a17090331d100b001590804e852mr22453225ple.19.1654489856828; Sun, 05 Jun 2022 21:30:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654489856; cv=none; d=google.com; s=arc-20160816; b=gFBxdoad3XyCUHv5qZyyP6eQQ0sF8gMz0inHchoq4qQvOWiSk1nOedtMlbnFgUG/mD P4L8UP3JJynudBUUs6ijJL7I+lAKLojUL+A9ZXF/gLSV9IlgLeR4e+QEcxANChntTkY3 GcVUsc8oGEdB16mtsBLgU7jgObxIgZD8VACmPZisxwR79IN+KathNcj+wRmfGoIE2nmS V3p99fmo8GFRcWE4AzSABBi3FkiL3htwh5CSSOdRyvCaROd2T4hYthIIfNW9Duuqb1eY cHyPuI/et96+QdifE8Vzl7fyVY41olWvO+kb3MkG6yAN0rpo6XBcbXjMPj0trh+8nZxx ZwjA== 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=n7AyK+2+qdCwTjgSc2O61Er8m50wo/oEB4WEsvunc6WJc8G95pRr+1YJtKvUqW7WWH 7+iueh8JEyGRcrsppe+QTttfiXbC9jANWaOFxIpGCsjoGguImqShD9mISRJK8oeZLSds gnNheqVfg+ldtu0E3HH7b788LCR6ZNy/9K700JdlM54sDk2t2edF/7MSpKF7AHNeQEII p+StnX9MwyuziqrZjZmk0mPqOyty3bX1N8tAaQGFslXvczFOw/Nf4rfdQmurpPfSvK+e AuCf0D23LGmAbCkoR4t45y+rQRII7FivzSZNjlSNqGN4bGCBMOnGs5Up4ips3CW0a1CG BT8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cbHR+D7V; 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 b27-20020a630c1b000000b003fb194f55f8si18461430pgl.432.2022.06.05.21.30.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 21:30:56 -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=cbHR+D7V; 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 14CA7EE33; Sun, 5 Jun 2022 20:57:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345000AbiFCRoo (ORCPT + 99 others); Fri, 3 Jun 2022 13:44:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345009AbiFCRn6 (ORCPT ); Fri, 3 Jun 2022 13:43:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E87DA5402D; Fri, 3 Jun 2022 10:42:25 -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 E20B2B8242D; Fri, 3 Jun 2022 17:42:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22E2AC3411C; Fri, 3 Jun 2022 17:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654278142; bh=NnEyWjMihEvGC1ycsFdaXgQ+EWmAJe/cwgy1WOjErkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbHR+D7VaTTYf0IXKrNmwR1xxzeRH5vWhRKiFzRLitDLE6Z1GKmLbhLP7B09hPoA0 E2YV8ERIkoiIz8C95sivFFr0zrUCSxJnPHLB+khnM9B/Laji9G0Yhg1iclxqXd6wRn fLxgz93zGGd3dVqW9rzFOSYgqJFEDklnK+0/jDx8= 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.19 23/30] dm stats: add cond_resched when looping over entries Date: Fri, 3 Jun 2022 19:39:51 +0200 Message-Id: <20220603173815.775398641@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603173815.088143764@linuxfoundation.org> References: <20220603173815.088143764@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)