From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 13056A04FF; Sun, 1 May 2022 11:18:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD3C84111B; Sun, 1 May 2022 11:18:35 +0200 (CEST) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by mails.dpdk.org (Postfix) with ESMTP id 0CF70410D4 for ; Sun, 1 May 2022 11:18:35 +0200 (CEST) Received: by mail-lj1-f179.google.com with SMTP id c15so15274037ljr.9 for ; Sun, 01 May 2022 02:18:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BVhLFb3EOVqrya1pDJEW8L8fCyzvwcIECGNQS0JHcEM=; b=VGORlHGKuqog7ONoTLj71FVy43gqQ6+1Md/NykV/P8wcn6XoMFrs+zGkYBoZCPuzQC SnVER9Zwxv2V7haTGu5pp6JOrV4K+v2Nze4POslAesxr2DZZcBD4B6K1pJ40zkfpUEBR N3TPpVoDhPswDDJ6pStmsopzqgiVrApVRc/vwodKgIhWigzUUWnAcZNQVIJQgCzOcWEU foxjkSZ0kkyjvJ79j6S2ncPLtDgvddncgnnYcyjV9YsKDjO7DiheBJ6kVoct6CUJ6hkP 3xv3ZDgz8L9Tdt8AAxRf+RVDd2YLYlewq03/0qfwgScVrsMjPurGrKtA6IF+RD/WtrV0 nvBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BVhLFb3EOVqrya1pDJEW8L8fCyzvwcIECGNQS0JHcEM=; b=y0a4BT1yDIGyHFz4mICHzH2H7srh0hER23oihPXM9zfTv/iySU1wM+BceDeN9WtQMA nrgojs73A6fAvh6Jwlg+wy/xHKCXr2k4lMehsV4BO7gyiltVEFXfvsTdtObcaTXFnB2y DnrHO6kBZf24MYqWHT8OCwUtCY4PZOATukDoJbJ4TbTKwIh1SkNSLSOfPWakq1H14F79 QARjJxwl6+mibP3q8YzUgrWvF0BDPnFRKb0DBc0Xv7/gnoYKxCl+5jpHCoSyK1fJDyjD GEOYa91oAdfB4J7mY6/RXk8dBkGSyd3aSvlEnjNUsBnooJppw4La7wXXpEKnnB6qVUcI mzMQ== X-Gm-Message-State: AOAM532igRjpdsVPUsX6JhqD/3GRZlM23jTF9v/kGJSOdJdfgfGJozy7 OQiXRUdwgLulwfZOPrvRdzM= X-Google-Smtp-Source: ABdhPJxWH3TNqojCRwjqCVShs3SlvpUh+FD0Wf5YoMJ01x3u4xL3RL1svStnp6hB1rB7Mk9CipJTuw== X-Received: by 2002:a2e:8789:0:b0:24f:124c:864a with SMTP id n9-20020a2e8789000000b0024f124c864amr4892626lji.164.1651396714631; Sun, 01 May 2022 02:18:34 -0700 (PDT) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id h9-20020a197009000000b0047255d21103sm396317lfc.50.2022.05.01.02.18.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 May 2022 02:18:34 -0700 (PDT) Date: Sun, 1 May 2022 12:18:33 +0300 From: Dmitry Kozlyuk To: Tyler Retzlaff Cc: dev@dpdk.org, thomas@monjalon.net, anatoly.burakov@intel.com, Narcisa Vasile Subject: Re: [PATCH v4 2/3] eal: implement functions for get/set thread affinity Message-ID: <20220501121833.439756f1@sovereign> In-Reply-To: <1650959442-29330-3-git-send-email-roretzla@linux.microsoft.com> References: <1648819793-18948-1-git-send-email-roretzla@linux.microsoft.com> <1650959442-29330-1-git-send-email-roretzla@linux.microsoft.com> <1650959442-29330-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 2022-04-26 00:50 (UTC-0700), Tyler Retzlaff: > Implement functions for getting/setting thread affinity. > Threads can be pinned to specific cores by setting their > affinity attribute. > > Windows error codes are translated to errno-style error codes. > The possible return values are chosen so that we have as > much semantic compatibility between platforms as possible. > > note: convert_cpuset_to_affinity has a limitation that all cpus of > the set belong to the same processor group. > > Signed-off-by: Narcisa Vasile > Signed-off-by: Tyler Retzlaff Acked-by: Dmitry Kozlyuk with two minor issues below. > +static int > +eal_query_group_affinity(void) > +{ > + SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infos = NULL; > + unsigned int *cpu_count = &cpu_map.cpu_count; > + DWORD infos_size = 0; > + int ret = 0; > + USHORT group_count; > + KAFFINITY affinity; > + USHORT group_no; > + unsigned int i; > + > + if (!GetLogicalProcessorInformationEx(RelationGroup, NULL, > + &infos_size)) { > + DWORD error = GetLastError(); > + if (error != ERROR_INSUFFICIENT_BUFFER) { > + log_early("Cannot get group information size, error %lu\n", error); This code is now called not only at initialization, but also after the logging is set up, in which case this line will not go into a redirected destination. I think there should not be log_early() at all in EAL, rte_log() could work from the very beginning. We're not in the kernel, stderr is available at once. So I would work around with a static flag maybe. [...] > +static int > +convert_cpuset_to_affinity(const rte_cpuset_t *cpuset, > + PGROUP_AFFINITY affinity) > +{ > + int ret = 0; > + PGROUP_AFFINITY cpu_affinity = NULL; > + unsigned int cpu_idx; > + > + memset(affinity, 0, sizeof(GROUP_AFFINITY)); > + affinity->Group = (USHORT)-1; > + > + /* Check that all cpus of the set belong to the same processor group and > + * accumulate thread affinity to be applied. > + */ > + for (cpu_idx = 0; cpu_idx < CPU_SETSIZE; cpu_idx++) { > + if (!CPU_ISSET(cpu_idx, cpuset)) > + continue; > + > + cpu_affinity = eal_get_cpu_affinity(cpu_idx); > + > + if (affinity->Group == (USHORT)-1) { > + affinity->Group = cpu_affinity->Group; > + } else if (affinity->Group != cpu_affinity->Group) { > + ret = ENOTSUP; Maybe worth a dedug log because the limitation is non-obvious.