From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC5A8FA3742 for ; Thu, 27 Oct 2022 20:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236904AbiJ0UDm (ORCPT ); Thu, 27 Oct 2022 16:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236832AbiJ0UD3 (ORCPT ); Thu, 27 Oct 2022 16:03:29 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09D49564E1 for ; Thu, 27 Oct 2022 13:03:28 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id i5-20020a1c3b05000000b003cf47dcd316so4964454wma.4 for ; Thu, 27 Oct 2022 13:03:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=5VjJAp0N2+61Oxh2IMIlFv8RGCM+I8VCYCw/pBRRGl4=; b=rDS5vXypkzMWqdwalT/qT+2EkHrOMl5WdG+1xqXQ95n/JeHKDOdgvcQYLdiBx7vVic q/9lvXpSW6KPOVLNXmUGPHDImAVmHe+vI8ruMWy0Dhf2/qMN6AFwsiabdxfLHw5EXNM5 SxAYtXcCmWxpHa+uyH79lp9JestzjrPfR8k+JX/ppBCfUSfgBFHrSY/4tdGbU/OsBCg2 yELITCt4Q43G3BFRwibHoG8pv3nFxcow2sWte7mD52ZFBUc7/H2lF9P7kqN/irY4aY8S gG2h1su2qka2iMZUr7bJ1vGZd5u0Xvl3c2r6EMowplLAmYDrBARvdXrkBZRH7lhdGZ7i jVMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5VjJAp0N2+61Oxh2IMIlFv8RGCM+I8VCYCw/pBRRGl4=; b=UWxlZT6nv+Bv4wRq2w2m44/UfKhf0oHYyzGr2Z4Oss0XaZw7gO+Q/P6F2Xi3s8lToW Vvqru5OqdEWbLdOIorXESejq+eQscYNhE+GpGC7wZztX5pyJr5dLvuinNjXL1f9aBzhm J62XdIEziCipLgwlbnF4VtykN/XcYm4ETfsxhUxjGv1uwaQ13NjUaUEojwxQHjoAx8SH 14+1+GLFRSMIyFIzZx0RUARCK0vfNbcHRjhzH12sCHBlpQf8DDCi+UEA/trmBfV+yASY 03JMeKJhKPACTm3KdtdQnPBf4dIYP+ZZl57HuF8Otib8sDu+/MJm/4vru0VXfgmrIqOk 64DA== X-Gm-Message-State: ACrzQf0Jua+v6EYtfx/One+XP9QN6/RymELPk9fjpPxntTJmMcgSIcte 5nDkaXLnPyPMXLtjciskOzJHpIYAmwxQLZRptMJF3g== X-Google-Smtp-Source: AMsMyM5pAaws2hi59KHD9u3VHAH4ISacGKoFe/jGcaPZMrcw5Mdnz9NoAiQcbpPYG/5E11g7KmXZkBv4iUy9Oo6f1QE= X-Received: by 2002:a05:600c:3b11:b0:3c6:c02d:babb with SMTP id m17-20020a05600c3b1100b003c6c02dbabbmr7040071wms.69.1666901006407; Thu, 27 Oct 2022 13:03:26 -0700 (PDT) MIME-Version: 1.0 References: <20221021211816.1525201-1-vipinsh@google.com> <20221021211816.1525201-6-vipinsh@google.com> In-Reply-To: From: Vipin Sharma Date: Thu, 27 Oct 2022 13:02:49 -0700 Message-ID: Subject: Re: [PATCH v6 5/5] KVM: selftests: Allowing running dirty_log_perf_test on specific CPUs To: Sean Christopherson Cc: "Wang, Wei W" , "pbonzini@redhat.com" , "dmatlack@google.com" , "andrew.jones@linux.dev" , "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 27, 2022 at 8:56 AM Sean Christopherson wrote: > > On Thu, Oct 27, 2022, Wang, Wei W wrote: > > On Wednesday, October 26, 2022 11:44 PM, Sean Christopherson wrote: > > > If we go this route in the future, we'd need to add a worker trampoline as the > > > pinning needs to happen in the worker task itself to guarantee that the pinning > > > takes effect before the worker does anything useful. That should be very > > > doable. > > > > The alternative way is the one I shared before, using this: > > > > /* Thread created with attribute ATTR will be limited to run only on > > the processors represented in CPUSET. */ > > extern int pthread_attr_setaffinity_np (pthread_attr_t *__attr, > > size_t __cpusetsize, > > const cpu_set_t *__cpuset) > > > > Basically, the thread is created on the pCPU as user specified. > > I think this is better than "creating the thread on an arbitrary pCPU > > and then pinning it to the user specified pCPU in the thread's start routine". > > Ah, yeah, that's better. > pthread_create() will internally call sched_setaffinity() syscall after creation of a thread on a random CPU. So, from the performance side there is not much difference between the two approaches. However, we will still need pin_this_task_to_pcpu()/sched_affinity() to move the main thread to a specific pCPU, therefore, I am thinking of keeping the current approach unless there is a strong objection to it. > > Probably we also don't need "bool pin_vcpus". > > Yeah, but for selftests shaving bytes is not exactly top priority, and having a > dedicated flag avoids the need for magic numbers. If Vipin had used -1, I'd > probably be fine with that, but I'm also totally fine using a dedicated flag too. > Same, it is not performance critical in this case to add a magical -1.