Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2989361pxj; Mon, 17 May 2021 15:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKgVd0mQTBf7aItDIX04Ai3s+3+b4IZG6E8VMnNKB3RSYJaZx2QPiKGLO88j0+pw3xqpYt X-Received: by 2002:a17:907:c13:: with SMTP id ga19mr2083046ejc.163.1621288961068; Mon, 17 May 2021 15:02:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621288961; cv=none; d=google.com; s=arc-20160816; b=BYt8idl9kWOW3NYQHqpe3MHS8A2gzoss1zfzOI0arbdIfz38aQqFThGyEDpuiS0lX3 1uxhEYdu5rq1j3OfmYqVFAzZQZcAl7ofu681VfWEzdKXyT+4kIPbo6ryVnyrHK1C1ekV 2jqpUjrqy8SqqhCcgyfeQJBICmbOBVWWMjqsePXjYcYzSc+prVNv9i8/59wiceF8QrP5 4trQ9OGvWgsBPEsEUS8U0G11K07saIeTBcUdcJu+UZjbaKwWlE6bEbfdWb+DX69Dlawm yWMzts5XL2Q3vISTv0MUKDXYkmHmFBB7vkIkOpA4xHKSzMzl+uxjT7GSpNALm4Gmb84H scFg== 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=FIVHEfzKj4v7Hs8F3qWlhr0d/xWLD5gHZ7GVIClXsgY=; b=Mlki/00SyjmIP+dXjLKOkk6qC4HZXhBO09TMJuCe4PkGdsDm4ehArxzmY5flLdqI4K Q1E2egRyodzobwQQbtsGwM63xk+G+gLo/iBi/frsyXzvJs0ik9JPYVYiZ+y1GIMXtWfn 0tFuDUPW9AOIVHOlxTDyJj9iM2NE+pMR8xAOxfYVty2ZBOWkIUz2F/TWRYoxWkbItHas 4dSCOaR9uBwdyul/W94uwD7UkVt4mlgkmMfMbka+UZ0aBaYofoLRD6CSOvYqFD3Iju7y +A8UxFU17zhPlfXKB7ButCxCBJ5iRGmZ3CqwgaCe7DOJ356eyZDh4pDVlb0UgWLNok/C WZdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mckI40kK; 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 r17si3782600edv.361.2021.05.17.15.02.18; Mon, 17 May 2021 15:02:41 -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=mckI40kK; 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 S238123AbhEQOMG (ORCPT + 99 others); Mon, 17 May 2021 10:12:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:58902 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238332AbhEQOKA (ORCPT ); Mon, 17 May 2021 10:10:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2B8B6135D; Mon, 17 May 2021 14:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260431; bh=g5rjZow19rjXfHtHPbJrpvnBwn2fXdgvXzqfHYq1wWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mckI40kKhxlXfMDwDXViCK6f7W56m9EuvohCtE1HCITlCR8vGwSrjBTmOStxyWkJk DYlCbbhrZgQuo9Vezy0ibd3a9J6KZddyYmM5jEDVivLoW1YDZCFJXGWlVXnvYVOb0s TOz1GeToYvjUBuIorEDjaPO8cAFD4h1ilafuytMg= 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.12 079/363] powerpc/mm: Add cond_resched() while removing hpte mappings Date: Mon, 17 May 2021 15:59:05 +0200 Message-Id: <20210517140305.269966775@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 7719995323c3..12de1906e97b 100644 --- a/arch/powerpc/mm/book3s64/hash_utils.c +++ b/arch/powerpc/mm/book3s64/hash_utils.c @@ -338,7 +338,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; @@ -351,8 +351,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