From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id D0F247128A for ; Wed, 8 Jun 2022 13:54:55 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB8687752 for ; Wed, 8 Jun 2022 13:54:55 +0200 (CEST) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 751C47725 for ; Wed, 8 Jun 2022 13:54:54 +0200 (CEST) Received: by mail-pl1-x634.google.com with SMTP id d22so17408946plr.9 for ; Wed, 08 Jun 2022 04:54:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bowdernet.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Tuik80Z22gCguyTKfwgtMJKF19G+FsFl1qf08bF8fEY=; b=nFy3aSZTbTudel29NmhJsSJ2BVCnSsPtNTii1QehgKWdLdlKhnPQmMumDHzGVpTMYC D5SSf09/ZAZ/s6gOZTK4scTK4hUbcZPhCKbN/lL6cw7px5M/o+8FFggGVItJug79PaJK EKythNV5P/dcr1nZVNU0+Y18VIRATNQo/6xEooSyhciQYP9hBmNr/0ZBI9YcUAep07LT 1oZBGEK7tLaMb94EaM/EOUjO15zfVQmdUH0ywega5W3lya2gKvc/x85mMYvzJrN+nRmK gjVegaCHR7CaJaYlcX0mI1cOrKjByUx4eOqTaA4R7LBk29QGw6izVOOs4hJ9jFKL44Ko xG8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Tuik80Z22gCguyTKfwgtMJKF19G+FsFl1qf08bF8fEY=; b=LnB1rVMeTMv2nFo4fQNOJiV3hPgobRkclx1o7llWttS0GOx9GWXr1djR0rWgnmRmqD uc+qKTqlJeOQtkpYPooe/Q1qFlDPcaVymUnlPp66j38CagvoDEAPqX8Gz3sNLLatzOLQ v7/rwGuK3IalJuCp2RmnJfsKOepEj+NLdsIsShcyor4ejCpnspKD+Qhk8unCz6rdKpOP U4ruepaD9A4s04XwjGuT1iKHCbyizPZT75uibFStMTKjPYl6fs2gS2YzemfTCBW2odnH zAtU3nK4wQkIt95Y/WRXrUQH/FfrnyJtjPDvurDpzQ7MIk0HKz0+53HUcwdxIcS12aIz 7ulg== X-Gm-Message-State: AOAM5308YM/+cTkJuUsecZW5XV8QnhWmRZ3fNmCo+2QMpHvoO/uF6IfF cnbIQJhCrdtmzyNdZYhJttySoN8pITEDxMnw X-Google-Smtp-Source: ABdhPJzHRRtysBjdb5r1dw6oJJmVqJ4akLZdQfjk6B5tO5h6FNlJysfeEHdObEqy/zi2VhgbZhf+cQ== X-Received: by 2002:a17:902:ebca:b0:15f:4cc5:f40f with SMTP id p10-20020a170902ebca00b0015f4cc5f40fmr34032205plg.96.1654689286513; Wed, 08 Jun 2022 04:54:46 -0700 (PDT) Received: from pve-dev.dbnet.in (c-24-19-168-226.hsd1.wa.comcast.net. [24.19.168.226]) by smtp.gmail.com with ESMTPSA id t6-20020a654b86000000b003fba6db1b50sm14902820pgq.85.2022.06.08.04.54.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 04:54:46 -0700 (PDT) From: Daniel Bowder To: pve-devel@lists.proxmox.com Cc: Daniel Bowder Date: Wed, 8 Jun 2022 04:54:25 -0700 Message-Id: <20220608115428.250668-3-daniel@bowdernet.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220608115428.250668-1-daniel@bowdernet.com> References: <20220608115428.250668-1-daniel@bowdernet.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [guesthelpers.pm, vmid.pid, bowdernet.com] X-Mailman-Approved-At: Wed, 08 Jun 2022 14:30:46 +0200 Subject: [pve-devel] [PATCH 2/5] fix #3593: Added vm core pinning pve-guest-common X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jun 2022 11:54:55 -0000 Signed-off-by: Daniel Bowder --- The second patch adds a utility function to obtain the pid of the VM, then calls taskset on that pid with the cpuset in the qm conf. This execution of taskset pins the VMs process to the defined cpu cores. This utility function acts similarly to the exec_hookscript utility function. In fact, in the third patch this utility function will be called just after the "post-start" call to hookscript. src/PVE/GuestHelpers.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/PVE/GuestHelpers.pm b/src/PVE/GuestHelpers.pm index 0fe3fd6..a8f54fa 100644 --- a/src/PVE/GuestHelpers.pm +++ b/src/PVE/GuestHelpers.pm @@ -82,6 +82,30 @@ sub guest_migration_lock { return $res; } +sub exec_taskset { + my ($conf, $vmid) = @_; + + return if !$conf->{cpuset}; + + eval { + # Obtain the vm PID from /run/qemu-server/$vmid.pid + PVE::Tools::run_command( + [ "cat", "/run/qemu-server/$vmid.pid" ], + outfunc => sub { + my $line = shift; + if ($line =~ m/^([0-9]+)$/) { + # Pin the PID to the cpuset + PVE::Tools::run_command( + [ "taskset", "--cpu-list", "--all-tasks", "--pid", $conf->{cpuset}, $1 ] + ); + } else { + warn "cpuset error: failed to obtain vm process id.\n"; + } + } + ); + }; +} + sub check_hookscript { my ($volid, $storecfg) = @_; -- 2.30.2