From patchwork Thu Apr 16 13:23:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 227596 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 866F4C352BE for ; Thu, 16 Apr 2020 15:37:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5CB3421D91 for ; Thu, 16 Apr 2020 15:37:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587051472; bh=Q6Ia7usDOLuZ4bedNUL50Ce4q2NYsM6H3bmyAwXYQEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=c/szlYPQnMNTyr+xYCFDmwUUR7/jZ3oR77ZWzyrVffukU8Yc7wrn2v+GpnAlF+86G JInbcW8B7FXLB7SXYiaNzXqJW+iNx36MT4fLx8siuj3W4bxzSfvEXVEr4PA/CiZQZC zBKR2Ulm1xlSqvSii+Yytr3Zhnu9sfclBhqHvmm8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408332AbgDPPhv (ORCPT ); Thu, 16 Apr 2020 11:37:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:51510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2897809AbgDPNjG (ORCPT ); Thu, 16 Apr 2020 09:39:06 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 57C002220A; Thu, 16 Apr 2020 13:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1587044345; bh=Q6Ia7usDOLuZ4bedNUL50Ce4q2NYsM6H3bmyAwXYQEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nbkhM+TYrGKGWLacrS15FPcIaW3jZc641y6CfnC5S0c+T7nrNzhemSocAQ3YPMM3K eL6eIA1Hx+1j7Vsw2PR/TXMToMrib+TEr6+Z5lohuDetPuP6D13JrYuHrXi+xMhVOX 3REDBBNwmKbRMsejci6n8Yo8/r1FOoqnveNPvx4U= 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.5 180/257] dm writecache: add cond_resched to avoid CPU hangs Date: Thu, 16 Apr 2020 15:23:51 +0200 Message-Id: <20200416131348.856133636@linuxfoundation.org> X-Mailer: git-send-email 2.26.1 In-Reply-To: <20200416131325.891903893@linuxfoundation.org> References: <20200416131325.891903893@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Mikulas Patocka commit 1edaa447d958bec24c6a79685a5790d98976fd16 upstream. Initializing a dm-writecache device can take a long time when the persistent memory device is large. Add cond_resched() to a few loops to avoid warnings that the CPU is stuck. Cc: stable@vger.kernel.org # v4.18+ Signed-off-by: Mikulas Patocka Signed-off-by: Mike Snitzer Signed-off-by: Greg Kroah-Hartman --- drivers/md/dm-writecache.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/md/dm-writecache.c +++ b/drivers/md/dm-writecache.c @@ -872,6 +872,7 @@ static int writecache_alloc_entries(stru struct wc_entry *e = &wc->entries[b]; e->index = b; e->write_in_progress = false; + cond_resched(); } return 0; @@ -926,6 +927,7 @@ static void writecache_resume(struct dm_ e->original_sector = le64_to_cpu(wme.original_sector); e->seq_count = le64_to_cpu(wme.seq_count); } + cond_resched(); } #endif for (b = 0; b < wc->n_blocks; b++) { @@ -1770,8 +1772,10 @@ static int init_memory(struct dm_writeca pmem_assign(sb(wc)->n_blocks, cpu_to_le64(wc->n_blocks)); pmem_assign(sb(wc)->seq_count, cpu_to_le64(0)); - for (b = 0; b < wc->n_blocks; b++) + for (b = 0; b < wc->n_blocks; b++) { write_original_sector_seq_count(wc, &wc->entries[b], -1, -1); + cond_resched(); + } writecache_flush_all_metadata(wc); writecache_commit_flushed(wc, false);