<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 1, 2018 at 8:55 AM, kemi <span dir="ltr"><<a href="mailto:kemi.wang@intel.com" target="_blank">kemi.wang@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, Everyone<br>
   I am new comer of LXC/LXD community, and want to run a container on a limited cpu set.<br>
<br>
  The followings are my steps:<br>
  a) lxd init<br>
  b) lxc launch Ubuntu:18.04 first<br>
  c) lxc stop first<br>
  d) lxc config set first limits.cpu 0  // set container running on CPU 0<br></blockquote><div><br></div><div>I'm not sure, but I believe "0" here means all cpu, and not pin to cpu 0?</div><div><br></div><div>Try changing this to "1", "0-0", and "1-2". Observe the difference.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  e) lxc start first<br>
  f) lxc exec first -- bash<br>
  g) nproc   // the expected result would be 1, however, it still equals to cpu number of host <br>
  h) ls /sys/devices/system/cpu   // the expected result should only include cpu0 directory, however, it's not<br>
<br></blockquote><div><br></div><div><br></div><div>g) and h) read files from /proc, not cgroup. You need lxcfs. You should already have that on ubuntu though.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
So, it seems that CPU cgroup has not been enabled in LXC/LXD, right?  The version of lxc is 2.0.11 on Ubuntu 16.04.<br>
Anyone can help me on that, thx very much.<br></blockquote><div><br></div><div>If this is a new install, I highly suggest you just switch to ubuntu 18.04 + lxd-3 host. </div><div>If you simply want to have "correct" /proc entries, make sure lxcfs is installed, and then restart lxd (if needed).</div><div><br></div><div>-- </div><div>Fajar</div></div></div></div>