Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2804317rdb; Mon, 4 Dec 2023 08:01:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IE7FCB4I6VtF+C/NjqulOaeVidTwiSdUsedcRInuv3eyDUxo8IySEoBGp5wtnXz881u+WUA X-Received: by 2002:a17:902:bb98:b0:1d0:9fdb:a961 with SMTP id m24-20020a170902bb9800b001d09fdba961mr1133882pls.32.1701705681641; Mon, 04 Dec 2023 08:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701705681; cv=none; d=google.com; s=arc-20160816; b=CDfUD0EY9SVqo1jSaCje1tFGbukc6r+CyOmY8EXy5sB4vPtXBaX6O+JbBRs+Ief7Dx eZAMOpjB9gednpVX1U37xiEcNMQLoJJ6d+3n9xuN9rAaBD0opoUADr7jx1VtT8QumlGc b6pYXtW6ngTtzp/XfVKfiiq/tRBSASlSWZhWMzj5kRfaz7KR2HS3cRIIqF/F2b9ifi8H AN6uDKWaS75M6q/7/tSWNEhZzeoGRTgeeWZbby39rnTzfE659++DupmlCRVaMwTNfxnC AzOQJrRsDg+d02b8go2MQgIfJcawPleXSXrv+0n6pb9uO0VOEu2ciZ629rfy4nuOoa+q b2SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=vu5tKdLWsp9uh1IlEpXyg0ZTTjJv3rNUrs1mjxuE+II=; fh=qaFDoKn91M+21pP2WDO2+0dSEf3n+9ulebs62BMRMY8=; b=r8onUwamq5tzZfXtTYvQXXd+g1cA0c64k167Tkp+H3z4kGvzQ2sGwIpsVWNumU5HAu NzYOsiaSm7oPP+0lzfb8vYt7F6eWjL1rYO10cqcLZ0Tin+oX+h2wv/PMIA5tZQ7tAMIE 4i0YsJG2bXdhYk1+r9h2PCPAJ/rZZU7hkhp2REjoijm/c9ntNv9cKtfQH8OscPOFTQwb 9yt5K3NqiCgGdOSup+yDApwxKmPMnCp/9d8QuaR1P6bpg34iPERSgezyQqH/eYxk1g37 44lORasv2yo6pF3Eoez9PallZvbpakxG8bQbxJSJW8p6Be35RUOGaGmd6tPcaLr/vnc8 3S/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B0IGHm62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id b6-20020a170903228600b001cfbb926859si7976751plh.387.2023.12.04.08.01.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:01:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B0IGHm62; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 42294807CB5B; Mon, 4 Dec 2023 08:00:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344322AbjLDQA3 (ORCPT + 99 others); Mon, 4 Dec 2023 11:00:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235025AbjLDQAX (ORCPT ); Mon, 4 Dec 2023 11:00:23 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3589711F for ; Mon, 4 Dec 2023 08:00:28 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id d9443c01a7336-1cfc4af9668so19595755ad.0 for ; Mon, 04 Dec 2023 08:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1701705628; x=1702310428; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vu5tKdLWsp9uh1IlEpXyg0ZTTjJv3rNUrs1mjxuE+II=; b=B0IGHm62IWoUTyGNnCFcK4MHHOp0E1uaM48di7b3KqoP+rLKMb9+XMrbpVOpALLmuK 4ryK02RmWaM6zB2mhpLE7vLCuQFjbiNVBV0z3xjwWJd4+MVP8PWenjIP5YJpIRteO6Kg IlE8Vi+ftUpsmyBxoVDYC5W6HhmitsnCo2+AB1TIiB5xh3cs/i/dPwL2pR8mu4Uw7iv2 XTPrruOOGTotlrNTPfyYHJb1ACiwdjLQXiVLkidPUpdKflxBhUcz7rJ7DHYcH4KWwAF1 2LNyn33cNYNO2QUdheKNL8iRVFRfLWJHDYJ1t0ow9pRuqPXczbaWMHz4C6sDTaJrOw31 Dqzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701705628; x=1702310428; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vu5tKdLWsp9uh1IlEpXyg0ZTTjJv3rNUrs1mjxuE+II=; b=A4OaR1NwW1Fc5lMBudqbZMYAKRsFdTxUCfNjv2T055jWr/TEHKtOL+il27p7DW3tJK kmxjB2ZFgHCq3wZ0bELVsMRFRWse+M/lSF6sDO70F6DK9BwoNZXKqjbJLVtP+/nxkU1T y7mTKoJIiKwurc5XiGByb8WBjBEwo7DbhVM2ycpfP9jxW8ucAL3atjvM5G1wItYFym5g sMLrN4nhw72Bd0OEXZjvWqnqJjr4AOQzRZv4hJTNE8slUXSWbkTaRIdPlTtUYJxiIYtc FfYy19pgmAFQSW+qccNxsZ7pGUdcyTZgdCbmau12sk892P//1oOOBiIWzo84GYc2iArP vleg== X-Gm-Message-State: AOJu0YwHaz/cHawNpmRKGld0fc2kvGmOOt+JyHaKljOnrd5SFZ6QJN1H YTKrBF2vrW1v+ZmrVbAUsV4qi4XDwyk= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:e88b:b0:1d0:83bc:5661 with SMTP id w11-20020a170902e88b00b001d083bc5661mr110010plg.5.1701705628175; Mon, 04 Dec 2023 08:00:28 -0800 (PST) Date: Mon, 4 Dec 2023 08:00:26 -0800 In-Reply-To: <87h6kymgzi.fsf@redhat.com> Mime-Version: 1.0 References: <20231203192422.539300-1-yury.norov@gmail.com> <20231203193307.542794-1-yury.norov@gmail.com> <20231203193307.542794-12-yury.norov@gmail.com> <87h6kymgzi.fsf@redhat.com> Message-ID: Subject: Re: [PATCH v2 13/35] KVM: x86: hyper-v: optimize and cleanup kvm_hv_process_stimers() From: Sean Christopherson To: Vitaly Kuznetsov Cc: Yury Norov , linux-kernel@vger.kernel.org, Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , kvm@vger.kernel.org, Jan Kara , Mirsad Todorovac , Matthew Wilcox , Rasmus Villemoes , Andy Shevchenko , Maxim Kuvyrkov , Alexey Klimov , Bart Van Assche , Sergey Shtylyov Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.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 (morse.vger.email [0.0.0.0]); Mon, 04 Dec 2023 08:00:43 -0800 (PST) On Mon, Dec 04, 2023, Vitaly Kuznetsov wrote: > > - for (i = 0; i < ARRAY_SIZE(hv_vcpu->stimer); i++) > > - if (test_and_clear_bit(i, hv_vcpu->stimer_pending_bitmap)) { > > - stimer = &hv_vcpu->stimer[i]; > > - if (stimer->config.enable) { > > - exp_time = stimer->exp_time; > > - > > - if (exp_time) { > > - time_now = > > - get_time_ref_counter(vcpu->kvm); > > - if (time_now >= exp_time) > > - stimer_expiration(stimer); > > - } > > - > > - if ((stimer->config.enable) && > > - stimer->count) { > > - if (!stimer->msg_pending) > > - stimer_start(stimer); > > - } else > > - stimer_cleanup(stimer); > > - } > > + for_each_test_and_clear_bit(i, hv_vcpu->stimer_pending_bitmap, > > + ARRAY_SIZE(hv_vcpu->stimer)) { Another nit, please align the indendation: for_each_test_and_clear_bit(i, hv_vcpu->stimer_pending_bitmap, ARRAY_SIZE(hv_vcpu->stimer)) { > > + stimer = &hv_vcpu->stimer[i]; > > + if (!stimer->config.enable) > > + continue; > > + > > + exp_time = stimer->exp_time; > > + > > + if (exp_time) { > > + time_now = get_time_ref_counter(vcpu->kvm); > > + if (time_now >= exp_time) > > + stimer_expiration(stimer); > > } > > + > > + if (stimer->config.enable && stimer->count) { > > + if (!stimer->msg_pending) > > + stimer_start(stimer); > > + } else > > + stimer_cleanup(stimer); > > Minor nitpick: it's better (and afair required by coding style) to use > '{}' for both branches here: Yeah, it's a hard requirement in KVM x86. > > if (stimer->config.enable && stimer->count) { > if (!stimer->msg_pending) > stimer_start(stimer); > } else { > stimer_cleanup(stimer); > } > > > + } > > } > > > > void kvm_hv_vcpu_uninit(struct kvm_vcpu *vcpu) > > Reviewed-by: Vitaly Kuznetsov > > -- > Vitaly >