Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp567725rdb; Tue, 19 Sep 2023 04:10:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF+brHc3UfqqM6IE1t/YHdjZxFO5q2khV9/FK/X12ACfxdOHiOQqRWTA513vzrlfDOXMr8e X-Received: by 2002:a05:6a20:13d0:b0:13a:fa9e:787b with SMTP id ho16-20020a056a2013d000b0013afa9e787bmr9584271pzc.12.1695121805419; Tue, 19 Sep 2023 04:10:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695121805; cv=none; d=google.com; s=arc-20160816; b=hdXD85OU8k3QuFPERi4bvpzYAqnhurUDC/xeMVuqeUAUeIpM8nfmeFiZt2RPkquKx1 DfRFOa76UbdEleXWgrb1GC5p3HWRn5y2TnKswRfMGgIRsroXZ9dIu1xd7JIEUxeh6SUC KLlG7EQs10Yk/lieuXMWhQMiviBvYfk429wdIZ6HssR51/JWZv3C9wBgJD9WJN9OqUYY a1Qp7N7VNT67f8J+AgmPfDGXRDdACOWAS6doGDan/YGr+clGjw9D4Mzb0hsCPy5X3qvj o3vDk0v8a26ETU2YktC3d2Jz7mBVFAhxDWGhoYLokwHQQrZaqcsIiXlcw5u1GYOzsVD4 AS9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=vfSKiKasFq+oxT2rx/srAsLPU3hbAgwW8pkV6FGayr8=; fh=/lhxu/ScgC3wE2UG94EHrFj0lFSGopW1/C43qnjOPtc=; b=OQlgTz/JW/lRLi6S/IYoPPK5xrfRuXN8ssG5KmtoTk6JAyGnHWjYCAkIzxbWxfPBoE cWK5uVegPAvIcIqxVyFFsU2ZJTA/MDftYjXPjaKOZT0CdYBLc0gqF+jqLrk84PLtKuJY BOd+C8jKXq760NLM5gMulpZZe9CoLJXrC1dgwTQYHwzva7jFr1viJXM46riTnaMIKwTD IFSExnOlKUZKKTMaWxrgLd12stVH8QVXNtVB1hX/nzmTvoOViHVJc2lSjp4AbOWLdweU EIG365MqXR1m+9xWLB7u7ZXpd9xGPh42rrBt/r0YVS5MO21U7Go9K9VSzDHUUuMdQdjH H8Kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RPcP891c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id x15-20020a056a00188f00b0068a49a550b9si403741pfh.139.2023.09.19.04.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 04:10:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RPcP891c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4207B8135690; Mon, 18 Sep 2023 23:42:58 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231546AbjISGm6 (ORCPT + 99 others); Tue, 19 Sep 2023 02:42:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229853AbjISGm5 (ORCPT ); Tue, 19 Sep 2023 02:42:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31AD7115 for ; Mon, 18 Sep 2023 23:42:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695105726; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vfSKiKasFq+oxT2rx/srAsLPU3hbAgwW8pkV6FGayr8=; b=RPcP891cZYLU3WFH6Ti1JwtDtZHWgEnvKtKoUM0pZLRdF5JSRd+NALG6Xd57BshShpTSPU PJa0VPbjY0nyGMSY0vE47/L06wnLXAl3haRdZPBdY4TDz/IJqiq5sqGucr52sSwnx1QZdQ MpALj9OXiMx5B9ZjUyC6njTeDFI8QSY= Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446-nDevAn9pOaifcbGJpD6erA-1; Tue, 19 Sep 2023 02:42:04 -0400 X-MC-Unique: nDevAn9pOaifcbGJpD6erA-1 Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-56c2d67da6aso3640030a12.2 for ; Mon, 18 Sep 2023 23:42:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695105723; x=1695710523; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vfSKiKasFq+oxT2rx/srAsLPU3hbAgwW8pkV6FGayr8=; b=b+vaYphcNT3I6aSO+5VyYFVUbIWyv8iuktFf484+6vfZpSLzxFSHjxMZi/L/ODMtYE fqClRE8+NTknRebivVPW9x7nKKeOI7quBTDSP1IKEnLmpmynabPPOlHB1ihLW7Wi6hYq Rdfk0yS9Lj1l+7YvJsRY2AAHI4CnzZ0ZgMatBTWLzrPR2gbhDqN8Zj6g18d7HyHqLtVP YmUryUjxajoopPUd3E4cs+REFJHz7mYmsppueX60Rp2bXmY4NsbL8IXGSbaUw3VbwyVk oYYcjd1BHDZkqegf+hVsPc+2VtUb3jNfc/SJxGHAvj9d+E5hsGTWC6chFxk+SftSqnm9 bpAw== X-Gm-Message-State: AOJu0Yz/IHtlzyeP+szaBxJSPpjmhN6KYs7F/VdBhBdVQJ83h5T35W8Y wahQikuVj2UwGw2g5KJYF/xZqJkmJjMUsCQ+EwLDlDUcWwNEoL4/YxCOnxHMFK/AnxniQPw3vSl aVa2nPhnFNgnhyTo8oGuyLKFW X-Received: by 2002:a05:6a20:394f:b0:14c:d105:2a59 with SMTP id r15-20020a056a20394f00b0014cd1052a59mr12035863pzg.55.1695105723145; Mon, 18 Sep 2023 23:42:03 -0700 (PDT) X-Received: by 2002:a05:6a20:394f:b0:14c:d105:2a59 with SMTP id r15-20020a056a20394f00b0014cd1052a59mr12035847pzg.55.1695105722843; Mon, 18 Sep 2023 23:42:02 -0700 (PDT) Received: from ?IPV6:2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5? ([2001:8003:e5b0:9f00:dbbc:1945:6e65:ec5]) by smtp.gmail.com with ESMTPSA id u10-20020a17090341ca00b001bbb7af4963sm9298281ple.68.2023.09.18.23.41.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Sep 2023 23:42:01 -0700 (PDT) Message-ID: Date: Tue, 19 Sep 2023 16:41:54 +1000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH] KVM: arm64: Fix soft-lockup on relaxing PTE permission Content-Language: en-US To: Oliver Upton Cc: kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, maz@kernel.org, james.morse@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, catalin.marinas@arm.com, will@kernel.org, qperret@google.com, ricarkol@google.com, tabba@google.com, bgardon@google.com, zhenyzha@redhat.com, yihyu@redhat.com, shan.gavin@gmail.com References: <20230904072826.1468907-1-gshan@redhat.com> <0f93a015-4f10-b53e-f67f-a84db43ca533@redhat.com> From: Gavin Shan In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 18 Sep 2023 23:42:58 -0700 (PDT) Hi Oliver, On 9/7/23 02:29, Oliver Upton wrote: > On Wed, Sep 06, 2023 at 08:26:24AM +1000, Gavin Shan wrote: > > [...] > >> It seems I didn't make it clear enough. The reason why I had the concern >> to avoid reading ctr_el0 is we read ctr_el0 for twice in the following path, >> but I doubt if anybody cares. Since it's a hot path, each bit of performance >> gain will count. >> >> invalidate_icache_guest_page >> __invalidate_icache_guest_page // first read on ctr_el0, with your code changes >> icache_inval_pou(va, va + size) >> invalidate_icache_by_line >> icache_line_size // second read on ctr_el0 > > That can be addressed by shoving the check deep into > invalidate_icache_by_line, which would benefit _all_ use cases of > I-cache invalidation by VA. I haven't completely made up my mind about > that, though, because of the consequences of a global invalidation. > Yes, of course. >>>> @size is guranteed to be PAGE_SIZE or PMD_SIZE aligned. Maybe >>>> we can just aggressively do something like below, disregarding the icache thrashing. >>>> In this way, the code is further simplified. >>>> >>>> if (size > PAGE_SIZE) { >>>> icache_inval_all_pou(); >>>> } else { >>>> icache_inval_pou((unsigned long)va, >>>> (unsigned long)va + size); >>>> } // parantheses is still needed >>> >>> This could work too but we already have a kernel heuristic for limiting >>> the amount of broadcast invalidations, which is MAX_TLBI_OPS. I don't >>> want to introduce a second, KVM-specific hack to address the exact same >>> thing. >>> >> >> Ok. I was confused at the first glance since TLB isn't relevant to icache. >> I think it's fine to reuse MAX_TLBI_OPS here, but a comment may be needed. >> Oliver, could you please send a formal patch for your changes? > > Yeah, I think I may have said it before, but this thing needs to be > called 'MAX_DVM_OPS'. I-cache invalidations and TLB invalidations become > DVMOps (Distributed Virtual Memory) in terms of CHI, which pile up at the > miscellaneous node in the mesh. > > Give me a day or two to convince myself of the right way to go about > this and I'll send out what I have. > Ok. 'MAX_DVM_OPS' sounds good and it's a new name to me anyway. Oliver, please let me know if you don't have time for this and need me to file the formal patches, based on your codes :) Thanks, Gavin