Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp4353621ybe; Mon, 16 Sep 2019 10:45:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVhwBAuOedwGUFPrIFbhKR7SIqWnJSPYNw0pZ4BCPwP5pkx45DiyOF/fMRwdDS8j/DKCfH X-Received: by 2002:aa7:cf81:: with SMTP id z1mr516958edx.224.1568655945612; Mon, 16 Sep 2019 10:45:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568655945; cv=none; d=google.com; s=arc-20160816; b=cNGMBh38p7EjgfTx9VRF8ePjRqvA0LKlhY4yv5A0GP338ZIufppoBfnzXWWe26cY4j oBWxWIR1XqeD0SGdGixZwgzUCbw8io1bFqnjpofh9BqLBF5QTG3DMJNTSBXn+b11Fh3Y vOVc/oFFXwOqWXYexTj/yl3Na05cpRsvtZn1/AuUI9ITQlJ28gcHAViXcC/oiQrkjKYO 5Br08fl+e5/u7+X9O9z0mJuxgqriMZEvyqonDrR19TEZsmaBjjXjvbNX9L++aXvHlm24 5TCdX2kfVPqrxWQOMtgYVoHNBo44FuoxbAeLzM1GgXBNRiFYTIkCg2jUhTlHh0qU4A4d ZiAQ== 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:to:from; bh=SAX2q6bPMeJEE+p1/Lp2DAhmzZf7N7WzSmEi6YApR/8=; b=JU8sNdeJ6LaAwmr/SKNVWwIZmpCtw7/Ru2LvFkLybRkXjNLv4h5Dfdzmhzlu8xxFEf uz2GiVR4l2vL0N3T4ypOD9cIVyLxH1pYEFUUK9AO7l1gi1JqMNWcgKx4ENCWLAZul/t6 UgackYCxKiP7+BEinEcXVWgk951UnnkyYocqQIvBm7wy8yvrzArK/BOKH1EBZrQsCnXS Ww9YUtitfa5tR1Go6lW32roe5TThyaRURPrGXKR2sArOEtmbNUbrAXJamZUf8LvpnsjH O2XmCdapXDXvScmGVvnNRJOpMDRbhhl6Ku8L2IN5gU5oTtiUdwa/BB0jyeEfbvPEXO2W XbmQ== 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 f17si23261143ede.380.2019.09.16.10.45.21; Mon, 16 Sep 2019 10:45:45 -0700 (PDT) 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 S1732251AbfIPJ5c (ORCPT + 99 others); Mon, 16 Sep 2019 05:57:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:30308 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732227AbfIPJ50 (ORCPT ); Mon, 16 Sep 2019 05:57:26 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8G9rRxL125704 for ; Mon, 16 Sep 2019 05:57:25 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2v27sn0vsj-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 16 Sep 2019 05:57:25 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 16 Sep 2019 10:57:24 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 16 Sep 2019 10:57:20 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8G9vItv44040340 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Sep 2019 09:57:18 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C64334C046; Mon, 16 Sep 2019 09:57:18 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 036A64C040; Mon, 16 Sep 2019 09:57:18 +0000 (GMT) Received: from pomme.com (unknown [9.145.76.175]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 16 Sep 2019 09:57:17 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, aneesh.kumar@linux.ibm.com, npiggin@gmail.com, linuxppc-dev@lists.ozlabs.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] powerpc/mm: call H_BLOCK_REMOVE when supported Date: Mon, 16 Sep 2019 11:55:43 +0200 X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190916095543.17496-1-ldufour@linux.ibm.com> References: <20190916095543.17496-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 19091609-0012-0000-0000-0000034C8596 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091609-0013-0000-0000-00002186FB01 Message-Id: <20190916095543.17496-3-ldufour@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-09-16_05:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1909160105 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now we do not call _BLOCK_REMOVE all the time when the feature is exhibited. Depending on the hardware and the hypervisor, the hcall H_BLOCK_REMOVE may not be able to process all the page size for a segment base page size, as reported by the TLB Invalidate Characteristics.o For each couple base segment page size and actual page size, this characteristic is telling the size of the block the hcall is supporting. Due to the involve complexity in do_block_remove() and call_block_remove(), and the fact currently a 8 size block is returned by the hypervisor, we are only supporting 8 size block to the H_BLOCK_REMOVE hcall. Furthermore a warning message is displayed at boot time in the case of an unsupported block size. In order to identify this limitation easily in the code,a local define HBLKR_SUPPORTED_SIZE defining the currently supported block size, and a dedicated checking helper is_supported_hlbkr() are introduced. For regular pages and hugetlb, the assumption is made that the page size is equal to the base page size. For THP the page size is assumed to be 16M. Signed-off-by: Laurent Dufour --- arch/powerpc/platforms/pseries/lpar.c | 35 +++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/lpar.c b/arch/powerpc/platforms/pseries/lpar.c index 98a5c2ff9a0b..e2ad9b3b1097 100644 --- a/arch/powerpc/platforms/pseries/lpar.c +++ b/arch/powerpc/platforms/pseries/lpar.c @@ -65,6 +65,13 @@ EXPORT_SYMBOL(plpar_hcall_norets); */ static int hblkr_size[MMU_PAGE_COUNT][MMU_PAGE_COUNT]; +/* + * Due to the involved complexity, and that the current hypervisor is only + * returning this value or 0, we are limiting the support of the H_BLOCK_REMOVE + * buffer size to 8 size block. + */ +#define HBLKR_SUPPORTED_BLOCK_SIZE 8 + #ifdef CONFIG_VIRT_CPU_ACCOUNTING_NATIVE static u8 dtl_mask = DTL_LOG_PREEMPT; #else @@ -993,6 +1000,15 @@ static void pSeries_lpar_hpte_invalidate(unsigned long slot, unsigned long vpn, #define HBLKR_CTRL_ERRNOTFOUND 0x8800000000000000UL #define HBLKR_CTRL_ERRBUSY 0xa000000000000000UL +/* + * Returned true if we are supporting this block size for the specified segment + * base page size and actual page size. + */ +static inline bool is_supported_hlbkr(int bpsize, int psize) +{ + return (hblkr_size[bpsize][psize] == HBLKR_SUPPORTED_BLOCK_SIZE); +} + /** * H_BLOCK_REMOVE caller. * @idx should point to the latest @param entry set with a PTEX. @@ -1152,7 +1168,11 @@ static inline void __pSeries_lpar_hugepage_invalidate(unsigned long *slot, if (lock_tlbie) spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags); - if (firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) + /* + * Assuming THP size is 16M, and we only support 8 bytes size buffer + * for the momment. + */ + if (is_supported_hlbkr(psize, MMU_PAGE_16M)) hugepage_block_invalidate(slot, vpn, count, psize, ssize); else hugepage_bulk_invalidate(slot, vpn, count, psize, ssize); @@ -1437,6 +1457,14 @@ void __init pseries_lpar_read_hblkr_characteristics(void) block_size = 1 << block_size; + /* + * If the block size is not supported by the kernel, report it, + * but continue reading the values, and the following blocks. + */ + if (block_size != HBLKR_SUPPORTED_BLOCK_SIZE) + pr_warn("Unsupported H_BLOCK_REMOVE block size : %d\n", + block_size); + for (npsize = local_buffer[idx++]; npsize > 0; npsize--) check_lp_set_hblk((unsigned int) local_buffer[idx++], block_size); @@ -1468,7 +1496,10 @@ static void pSeries_lpar_flush_hash_range(unsigned long number, int local) if (lock_tlbie) spin_lock_irqsave(&pSeries_lpar_tlbie_lock, flags); - if (firmware_has_feature(FW_FEATURE_BLOCK_REMOVE)) { + /* + * Currently, we only support 8 bytes size buffer in do_block_remove(). + */ + if (is_supported_hlbkr(batch->psize, batch->psize)) { do_block_remove(number, batch, param); goto out; } -- 2.23.0