UNIX: script to test resource allocation?

Discussion in 'OT Technology' started by trouphaz, May 27, 2008.

  1. trouphaz

    trouphaz New Member

    Joined:
    Sep 22, 2003
    Messages:
    2,666
    Likes Received:
    0
    So, as I mentioned earlier, I'm working with Solaris Zones at work. I'm testing out some resource management and wanted to verify that a particular zone cannot use more resources than I've locked them into. Does anyone have any scripts that they use for running a system through its paces that might help? I'd like to make sure that I cannot allocate more than the memory that I've set as the cap and also make sure it isn't using more than 2 processors. I'm hoping that the 64-pseudo processors of the CoolThreads processors can be divided up by thread instead of by proc or by core. (For your edification, the new-ish Sparc CoolThreads processors can have up to 8 cores where each core can handle up to 8 threads at a time making a 1-CPU server behave almost like a 64-CPU system.)
     
  2. P07r0457

    P07r0457 New Member

    Joined:
    Sep 20, 2004
    Messages:
    28,491
    Likes Received:
    0
    Location:
    Southern Oregon
    hyper-threading on steroids, eh?

    Not really sure on solaris, but I know the linux kernel needs to be of the SMP-variety to work with HT, and the virtual thread is treated as a stand-alone core. So with linux, at least, it would be treated as a 64-core system instead of a 8-core, with 8-threads per core, machine.
     
  3. Peyomp

    Peyomp New Member

    Joined:
    Jan 11, 2002
    Messages:
    14,017
    Likes Received:
    0
    More like hyper-threads are fake coolthreads.
     
  4. Mike99TA

    Mike99TA I don't have anything clever to put here right now

    Joined:
    Oct 3, 2001
    Messages:
    4,553
    Likes Received:
    0
    Location:
    Greenville, SC
    If you just want to make sure you can't allocate more memory then the zone has available you could write a tiny little C program (and compile/run it obviously) that uses malloc and allocates chunks of memory in a loop and if it gives an error print how much it has already allocated, that will tell you if you can still allocate more than the desiginated amount.

    ie: run a while loop that runs until the return status of malloc is unsuccessful, each malloc allocates 100MB of memory and adds that to the total MB allocated - once it can no longer allocate 100MB have it echo the total amount allocated already and exit. Voila, now you know how much you were able to allocate.
     
  5. trouphaz

    trouphaz New Member

    Joined:
    Sep 22, 2003
    Messages:
    2,666
    Likes Received:
    0
    Wirelessly posted via wap.offtopic.com (Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; PPC; 240x320) BlackBerry8703e/4.1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/105)

    Mike, that's exactly what I ended up doing. Though I didn't make up the app myself. I found it on some linux site, modified it a little and compiled it with gcc. I set the physical memory cap to 2Gb and it does nothing. I can allocated over 20Gb with no issue. I'm working with Sun's kernel team now.
     
  6. Mike99TA

    Mike99TA I don't have anything clever to put here right now

    Joined:
    Oct 3, 2001
    Messages:
    4,553
    Likes Received:
    0
    Location:
    Greenville, SC
    Bummer. We actually did test this with Xen on SLES10. It successfully limited memory on the guest OS. Not only that but you can actually modify the number of CPUs and the amount of memory on a guest OS on-the-fly from the host system and it will update automatically. Its the coolest thing I've ever seen on a computer. You can literally drop the number of virtual CPUs from 8 to 2 and the amount of memory from 8GB to 1GB and then watch the top on the guest OS show the CPUs drop down to 2 (and even watch it spread all the threads among the remaining CPUs) and the memory quickly decreases down to 1GB, without causing any problems.

    Works great for scheduling jobs on a virtual machine - if you have a system with 5 VMs on it you could take 4 of them down to half CPUs and memory, give the CPUs and Memory to the 5th one, have it run processing/etc, then spread the CPUs/memory back out.
     

Share This Page