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 X-Spam-Level: X-Spam-Status: No, score=-0.5 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DE92C433E0 for ; Thu, 18 Mar 2021 14:56:29 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CB80364F68 for ; Thu, 18 Mar 2021 14:56:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB80364F68 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1lMu49-0006br-G1; Thu, 18 Mar 2021 10:56:01 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lMu44-0006ba-Kd for kernelnewbies@kernelnewbies.org; Thu, 18 Mar 2021 10:55:56 -0400 Received: by mail-pl1-x62b.google.com with SMTP id t20so1428226plr.13 for ; Thu, 18 Mar 2021 07:55:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=user-agent:from:to:subject:date:message-id:mime-version; bh=Rm48AMOUBMJs0J9Z2SENf3N77u6YWENBpTHiGwRxpH4=; b=OLZRe4LMzb9MDaSPdONnloM3ZuJGu0zxhiUM8+iIMti141/xFTR8c32k45CWMdkOar rnLutC29pM6J67oNC3abFmhV+503frvJcOtxvICZYtQ+CmqS/ZNaLpk4+yV6uSaKbn18 OIXGNEIJHTr+LmQWRw/22yMpm8zwudFbvg0VAxeg296InloIoG77wEQiSpmZvAtRYQaJ CqLIubKO6ye/TpdIE9GZ7IcMjILLpNi3+ibwHDHcKP6Z6MwbN7gROggpa4CVbDfSLizC srV7CVCRBz6udNCoyArJrn2jz1G5W97vwaUTuIqbAhu8E9sNHxGPLCd1YtsGbUyf1Pz8 GhaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:user-agent:from:to:subject:date:message-id :mime-version; bh=Rm48AMOUBMJs0J9Z2SENf3N77u6YWENBpTHiGwRxpH4=; b=diS84Y1Byljze0MIjlpU9ZCK5iOa2BRz1+FNsFXnvzOhiEijo1gatwLyGwIuj9G7BV ezCAY9qB6jG2a+CJeuvBcv016rrOdnZCaegdBC5DFIYvR2CZ119wRsYvPyje92dKt37Q vIMAr+AOGu04Sd8akUwmHWurJmDgs1jqxnChZQaXtgRvNAHbzEVhnV6gpduBhoNVt1Qw N6fcwQpzbjp2Wz9z5Jp6ITPlppkvRgmzaDQIciFM/pmAo0hWgBOD6izWcqPCVOs9PvWm K06FJFd0zqvVVVHew6hploI1W2LxYm87tj6j6vnlFjdmROBGaZlaR/1cBLxHMwcdfAG8 rbQw== X-Gm-Message-State: AOAM531RWD7Bhw5SAgMLQpi4/mhY0388weJQuKVMfaK1QZwg5P0vK6S+ t3kGQhfyZ05y+42oE9fFuKc2YHXOQ6g= X-Google-Smtp-Source: ABdhPJzbnmz8JDOBhWBqoMQMmLajZwgVm/o9Q0Cc7ZofJtY+pJE+j7Aaj6hgQ/2bzk/D1YtatMN7YA== X-Received: by 2002:a17:90a:3be4:: with SMTP id e91mr4645303pjc.113.1616079353705; Thu, 18 Mar 2021 07:55:53 -0700 (PDT) Received: from pop-os ([1.234.154.110]) by smtp.gmail.com with ESMTPSA id y8sm2607213pjb.11.2021.03.18.07.55.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 07:55:53 -0700 (PDT) User-agent: mu4e 1.5.7; emacs 28.0.50 From: Junyeong Jeong To: kernelnewbies@kernelnewbies.org Subject: /sys/devices/system/cpu/possible is immutable? Date: Thu, 18 Mar 2021 23:10:18 +0900 Message-ID: <87a6r01pfs.fsf@gmail.com> MIME-Version: 1.0 X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kernelnewbies-bounces@kernelnewbies.org Hello everyone :) I hope that kernelnewbies mailing list is a suitable place for asking my question. I wonder that possible-CPU-mask(/sys/devices/system/cpu/possible) can be changed after boot in some way or other. I read that it is fixed at boot time (https://elixir.bootlin.com/linux/v5.8/source/include/linux/cpumask.h#L50). But I am not convinced that it is really immutable even if some cgroup or virtualization magic is used. Let me account for why I am curious about it. Nowadays I am developing BPF library written in rust language. In order to call `bpf_lookup_elem()` to get values from BPF_MAP_TYPE_PERCPU_ARRAY in userspace, we need to know the correct number of per-cpu areas before calling it. Because an out-buffer for multiple per-cpu values should be allocated and passed to the `bpf_lookup_elem()`. But this process is strongly based on the assumption that the number of per-cpu area is always immutable. I am referring to /sys/devices/system/cpu/possible file to get to know the number of per-cpu areas. I don't know the better way for figuring out the number. What I am anxious about is that the number of per-cpu areas varies from time to time under some circumstances with cgroup or virtualization magic. So I checked some cgroup and virtualization ordinary use-cases which did not affect the possible-CPU-mask. -- 1. $ docker run --cpuset-cpus=0-3 -it ubuntu:20.10 bash This does not affect /sys/devices/system/cpu/possible at all. The value it contains is the same with the value of the host machine. 2. $ virsh setvcpus --current ubuntu20.10 5 Before starting guest OS, the number of maximum vCPU was set to 8 and current vCPU was set to 4. While guest OS is running, I changed the number of vCPU to 5. And _inside guest OS_, I enabled the new CPU by setting /sys/devices/system/cpu/cpu4/online to 1. But /sys/devices/system/cpu/possible of guest OS did not change as expected. -- While I was conducting some tests, I realized that it's not possible to prove the immutability of possible-CPU-mask using inductive method. Because there must be some corner cases that I can never imagine. Can anyone explain that possible-CPU-mask and the number of per-cpu areas never change after boot-time even by cgroup magic or some tricks from outside of hypervisors? Thanks, Junyeong _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies