Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3419977ybx; Sun, 3 Nov 2019 18:37:10 -0800 (PST) X-Google-Smtp-Source: APXvYqyLZwUNPredW6tU39YZnYGoKC1FyD+xBHiUL49h90i5Em3ht8aPmG7Nlm8oYVtDhMF6eDu8 X-Received: by 2002:a17:906:f756:: with SMTP id jp22mr8224568ejb.234.1572835030600; Sun, 03 Nov 2019 18:37:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572835030; cv=none; d=google.com; s=arc-20160816; b=DERT8dGqaAsfp+zVorkJ4B5xdTploa2MnkXlAh1v/5UdUS1T3+bnHxD6jNgscBSVIy b24YeMG8TKPYVACXMRrXok7fyaC06CUxaRPGJXaKoPustWzxEtyvGzO9S6fOUtSiHoh8 yL2WgWDEjxGkcM9Ri8vrQbYu7oTdXoGjpm+QorH8dqmke2IJwVP3Tg4863a8pl9otwAF C5pF5ziS2PKzHMSvAIzl5AvQ6GkITyCa+8CLaHNa/6CtYWz8dnAAccItR+F/u0vFzL52 eV7aQeX0Bnueq89FS3skhlT5t0gLpMzjVMBHlrvN1OpzQKoTSYlTpnRLDr4Klu1ZY49n mJdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:subject:cc:to:from; bh=gPqlvfnRjWKGoG6KiBqlfp6qpp92fqpQAiST40s05zo=; b=dPVCFkfDoAFSi1vf+qFkaJ2EeM6VGLjuJSLo0IokW/zdAzXgyqLtyDju3ctNlzSq4/ QWroYE6wiP0dArPxNMY+KMWTU536DFMsa9v9wZOXfIuSidEFKLQkaQrgrARIWbPNOEO5 Y0we01Eym7N+sPkC5J2W3y2edWTxkojT6H0iC/M/gN5oBP3q+2CbycP2yc4F0JyS+jSX /hI7EoewuxUTAHUmvuPQNviD8ArH2vKbraJFBJXCSLxxkjhChZBYk4Yjn+sMZ/PXp7Vm x8tFxetyNdpZHgN+97mpBZyJkwjGqfunKamsQlZF14qvKZkqegaR5X/Q+ebH6JqAJOnk 4pdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id mh20si338158ejb.268.2019.11.03.18.36.46; Sun, 03 Nov 2019 18:37:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729107AbfKDCep (ORCPT + 99 others); Sun, 3 Nov 2019 21:34:45 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:3518 "EHLO mx0b-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728227AbfKDCeo (ORCPT ); Sun, 3 Nov 2019 21:34:44 -0500 Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id xA42WQDg012869 for ; Sun, 3 Nov 2019 21:34:43 -0500 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2w14m2ru09-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 03 Nov 2019 21:34:43 -0500 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 4 Nov 2019 02:34:40 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 4 Nov 2019 02:34:37 -0000 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id xA42Y1uZ39256520 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 4 Nov 2019 02:34:02 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8E53011C04C; Mon, 4 Nov 2019 02:34:36 +0000 (GMT) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3AC5511C04A; Mon, 4 Nov 2019 02:34:36 +0000 (GMT) Received: from ozlabs.au.ibm.com (unknown [9.192.253.14]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 4 Nov 2019 02:34:36 +0000 (GMT) Received: from adsilva.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 6E9DDA01D6; Mon, 4 Nov 2019 13:34:34 +1100 (AEDT) From: "Alastair D'Silva" To: alastair@d-silva.org Cc: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , Christophe Leroy , Greg Kroah-Hartman , Thomas Gleixner , Qian Cai , Nicholas Piggin , Allison Randal , Andrew Morton , David Hildenbrand , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 5/6] powerpc: Chunk calls to flush_dcache_range in arch_*_memory Date: Mon, 4 Nov 2019 13:32:57 +1100 X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191104023305.9581-1-alastair@au1.ibm.com> References: <20191104023305.9581-1-alastair@au1.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19110402-0028-0000-0000-000003B25911 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19110402-0029-0000-0000-00002474AAB4 Message-Id: <20191104023305.9581-6-alastair@au1.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-11-04_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1911040026 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alastair D'Silva When presented with large amounts of memory being hotplugged (in my test case, ~890GB), the call to flush_dcache_range takes a while (~50 seconds), triggering RCU stalls. This patch breaks up the call into 1GB chunks, calling cond_resched() inbetween to allow the scheduler to run. Signed-off-by: Alastair D'Silva --- arch/powerpc/mm/mem.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 54d61ba15e93..a7b662fc02c8 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -104,6 +104,27 @@ int __weak remove_section_mapping(unsigned long start, unsigned long end) return -ENODEV; } +#define FLUSH_CHUNK_SIZE SZ_1G +/** + * flush_dcache_range_chunked(): Write any modified data cache blocks out to + * memory and invalidate them, in chunks of up to FLUSH_CHUNK_SIZE + * Does not invalidate the corresponding instruction cache blocks. + * + * @start: the start address + * @stop: the stop address (exclusive) + * @chunk: the max size of the chunks + */ +static void flush_dcache_range_chunked(unsigned long start, unsigned long stop, + unsigned long chunk) +{ + unsigned long i; + + for (i = start; i < stop; i += chunk) { + flush_dcache_range(i, min(stop, start + chunk)); + cond_resched(); + } +} + int __ref arch_add_memory(int nid, u64 start, u64 size, struct mhp_restrictions *restrictions) { @@ -120,7 +141,8 @@ int __ref arch_add_memory(int nid, u64 start, u64 size, start, start + size, rc); return -EFAULT; } - flush_dcache_range(start, start + size); + + flush_dcache_range_chunked(start, start + size, FLUSH_CHUNK_SIZE); return __add_pages(nid, start_pfn, nr_pages, restrictions); } @@ -137,7 +159,8 @@ void __ref arch_remove_memory(int nid, u64 start, u64 size, /* Remove htab bolted mappings for this section of memory */ start = (unsigned long)__va(start); - flush_dcache_range(start, start + size); + flush_dcache_range_chunked(start, start + size, FLUSH_CHUNK_SIZE); + ret = remove_section_mapping(start, start + size); WARN_ON_ONCE(ret); -- 2.21.0