Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp299988pxj; Tue, 18 May 2021 03:47:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvGx3bS2aDXwJ/U57KTTBtF3GK6hSh4gxI7d+iFxpBNDEzROtTMzIJ7EgWkThhKkV+TFNV X-Received: by 2002:a17:906:a51:: with SMTP id x17mr5401608ejf.25.1621334877893; Tue, 18 May 2021 03:47:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621334877; cv=none; d=google.com; s=arc-20160816; b=hT6zjpk8g6vRO+eVI+3FsI5X4R7yJzM0WCDuCGoDIY3uhsUKtAKZXpfZTiUklxNBOv rewak7oTsXYQUw+mZvMCh055149zxtqmEPznq2zNoebEis4BjT7D5SmYaTrePSRbbyjd 5p6a2EUcO7OO6f5kYGGJKnCXFru+LBMRWLzqKTwuyfjmjhsmEiJKimJ7jsHe3T+H5Oeg KX1Yd+Bp9rruD/2w5o5Gd2COCAimi3hOsQ5VNhA4m36tL9ljmbhT2JjdoY37E0Ue9Aaw BwE2kxMZqzdoqea9qjRzw12Qj6XC78E+ZD2XQOOGm1sBvCL1NJccl+AkyfF3yMworZrp /s7w== 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=WyJP1Ys+yFe/fQ7AfR4CMmhUy4Bgd4fEYHFSkqIXDQM=; b=gJbprffVbbyTetu0TtzzUnx+7jMc1/LAvWgWwVDsVWnhHyMdqZfPmemSe92sXs160b Ly6aFcEFbepqtXADq7UKqEI3LI4AW2gN2bNw8P3RhMocJiaFh6AL/3Vyx8xnpn0jILL/ KEGd9dfx6bd8bWkvZIOKJuc8ezw4HZOEpD3Djo6b7VouyRylZhJ8anmmlfT22kzCTV6b zk+EIO5OKkqMWL3e8MYieo0zBAkFQbtfIItxqTLSK9MC3ldOs0XSlZX2WOexd0r7LcVy AD/jHn3K5uclJe12b0KdJFArDflPxVorQ3+UgOpBdZN/Vkqa4qR2y7rqHuzLZ3C9d/cs kLmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="D/eXaPp1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q19si18082970ejd.250.2021.05.18.03.47.35; Tue, 18 May 2021 03:47:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="D/eXaPp1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243822AbhEQPO6 (ORCPT + 99 others); Mon, 17 May 2021 11:14:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:47750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242845AbhEQPEz (ORCPT ); Mon, 17 May 2021 11:04:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 96C6561622; Mon, 17 May 2021 14:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261711; bh=aTRJM9PX6GuayuMjXAlg4d6sNsLrbWdta4625LtSnns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/eXaPp1hoXDZ3sVFiK900maeiuDoKPpBonCsBRzswO8DHN4oLtr4oDUWNbAkC3O6 i6w+ixhc3tkjXMM12bZxHxSR8isPalG9bPYx13Pt63hSK7wqTBxqPjjbbU1rgSiRlC uTkxDVhy72mhabe8+tUK8t9dMNSYNs0sWN5F8apQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Aneesh Kumar K.V" , Vaibhav Jain , Christophe Leroy , Michael Ellerman , Sasha Levin Subject: [PATCH 5.10 055/289] powerpc/mm: Add cond_resched() while removing hpte mappings Date: Mon, 17 May 2021 15:59:40 +0200 Message-Id: <20210517140307.056034393@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vaibhav Jain [ Upstream commit a5d6a3e73acbd619dd5b7b831762b755f9e2db80 ] While removing large number of mappings from hash page tables for large memory systems as soft-lockup is reported because of the time spent inside htap_remove_mapping() like one below: watchdog: BUG: soft lockup - CPU#8 stuck for 23s! NIP plpar_hcall+0x38/0x58 LR pSeries_lpar_hpte_invalidate+0x68/0xb0 Call Trace: 0x1fffffffffff000 (unreliable) pSeries_lpar_hpte_removebolted+0x9c/0x230 hash__remove_section_mapping+0xec/0x1c0 remove_section_mapping+0x28/0x3c arch_remove_memory+0xfc/0x150 devm_memremap_pages_release+0x180/0x2f0 devm_action_release+0x30/0x50 release_nodes+0x28c/0x300 device_release_driver_internal+0x16c/0x280 unbind_store+0x124/0x170 drv_attr_store+0x44/0x60 sysfs_kf_write+0x64/0x90 kernfs_fop_write+0x1b0/0x290 __vfs_write+0x3c/0x70 vfs_write+0xd4/0x270 ksys_write+0xdc/0x130 system_call+0x5c/0x70 Fix this by adding a cond_resched() to the loop in htap_remove_mapping() that issues hcall to remove hpte mapping. The call to cond_resched() is issued every HZ jiffies which should prevent the soft-lockup from being reported. Suggested-by: Aneesh Kumar K.V Signed-off-by: Vaibhav Jain Reviewed-by: Christophe Leroy Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20210404163148.321346-1-vaibhav@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/mm/book3s64/hash_utils.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/mm/book3s64/hash_utils.c b/arch/powerpc/mm/book3s64/hash_utils.c index 24702c0a92e0..0141d571476c 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -336,7 +336,7 @@ repeat: int htab_remove_mapping(unsigned long vstart, unsigned long vend, int psize, int ssize) { - unsigned long vaddr; + unsigned long vaddr, time_limit; unsigned int step, shift; int rc; int ret = 0; @@ -349,8 +349,19 @@ int htab_remove_mapping(unsigned long vstart, unsigned long vend, /* Unmap the full range specificied */ vaddr = ALIGN_DOWN(vstart, step); + time_limit = jiffies + HZ; + for (;vaddr < vend; vaddr += step) { rc = mmu_hash_ops.hpte_removebolted(vaddr, psize, ssize); + + /* + * For large number of mappings introduce a cond_resched() + * to prevent softlockup warnings. + */ + if (time_after(jiffies, time_limit)) { + cond_resched(); + time_limit = jiffies + HZ; + } if (rc == -ENOENT) { ret = -ENOENT; continue; -- 2.30.2