From 129af8ee3ed32f5d8780cb69ee1a1786f0ef0b87 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 10 Mar 2008 15:36:44 +0000 Subject: [PATCH] -Use yield in child process data collection loops to avoid cycling needlessly, what was happing implicitly with sleep, the part that mattered -Copy hardeths redundantly, still need to pick one definitive place and go with that git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@738 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/blade.pm | 2 ++ xCAT-server-2.0/lib/xcat/plugins/ipmi.pm | 2 ++ xCAT-server-2.0/sbin/xcatd | 5 +++-- xCAT-server-2.0/share/xcat/postscripts/hardeths | 9 +++++++++ 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 xCAT-server-2.0/share/xcat/postscripts/hardeths diff --git a/xCAT-server-2.0/lib/xcat/plugins/blade.pm b/xCAT-server-2.0/lib/xcat/plugins/blade.pm index f44f5b538..3b4cd9b0c 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/blade.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/blade.pm @@ -3,6 +3,7 @@ package xCAT_plugin::blade; #use Net::SNMP qw(:snmp INTEGER); use xCAT::Table; +use Thread qw(yield); use xCAT::Utils; use IO::Socket; use SNMP; @@ -1101,6 +1102,7 @@ sub forward_data { close($rfh); } } + yield; #Try to avoid useless iterations as much as possible return $rc; } diff --git a/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm b/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm index 5fd5dd21d..e9741b382 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/ipmi.pm @@ -8,6 +8,7 @@ package xCAT_plugin::ipmi; use Storable qw(store_fd retrieve_fd thaw freeze); use xCAT::Utils; +use Thread qw(yield); require Exporter; @ISA = qw(Exporter); @@ -4541,6 +4542,7 @@ sub forward_data { #unserialize data from pipe, chunk at a time, use magic to de close($rfh); } } + yield; #Avoid useless loop iterations by giving children a chance to fill pipes return $rc; } diff --git a/xCAT-server-2.0/sbin/xcatd b/xCAT-server-2.0/sbin/xcatd index cdec46be0..61f08da64 100755 --- a/xCAT-server-2.0/sbin/xcatd +++ b/xCAT-server-2.0/sbin/xcatd @@ -9,6 +9,7 @@ use Storable qw(freeze thaw); use xCAT::Utils; use File::Path; use Time::HiRes qw(sleep); +use Thread qw(yield); use xCAT::Client submit_request; use IO::Socket::SSL; @@ -645,7 +646,7 @@ sub relay_dispatch { close($rin); } } - sleep (0.01); #Again, try not to overwhelm the system + yield; #At this point, explicitly yield to other processes. If children will have more data, this process would otherwise uselessly loop on data that never will be. If children are all done, still no harm in waiting a short bit for a timeslice to come back return scalar(@ready_ins); } @@ -914,7 +915,7 @@ sub relay_fds { #Relays file descriptors from pipes to children to the SSL socke close($rfh); } } - sleep (0.01); #This gets called in a loop a lot, this takes the edge off + yield; #Give other processes, including children, explicit control, to avoid uselessly aggressive looping return $rc; } diff --git a/xCAT-server-2.0/share/xcat/postscripts/hardeths b/xCAT-server-2.0/share/xcat/postscripts/hardeths new file mode 100644 index 000000000..7c5bbae2f --- /dev/null +++ b/xCAT-server-2.0/share/xcat/postscripts/hardeths @@ -0,0 +1,9 @@ +for nic in `ifconfig -a|grep -B1 "inet addr"|awk '{print $1}'|grep -v inet|grep -v -- --|grep -v lo`; do + IPADDR=`ifconfig $nic |grep "inet addr"|awk '{print $2}' |awk -F: '{print $2}'` + NETMASK=`ifconfig $nic |grep "inet addr"|awk '{print $4}' |awk -F: '{print $2}'` + sed -i s/BOOTPROTO=dhcp/BOOTPROTO=none/ /etc/sysconfig/network-scripts/ifcfg-$nic + echo IPADDR=$IPADDR >> /etc/sysconfig/network-scripts/ifcfg-$nic + echo NETMASK=$NETMASK >> /etc/sysconfig/network-scripts/ifcfg-$nic +done +sed -i "s/HOSTNAME.*/HOSTNAME=`hostname`/" /etc/sysconfig/network +