From a9a7703ed5ba548f48df021ef7e49960fedceb48 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Thu, 24 Nov 2011 09:24:24 +0000 Subject: [PATCH] add Huge Page Memory supporting item git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.6@11048 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/FSPcfg.pm | 24 ++- perl-xCAT/xCAT/FSPvm.pm | 230 ++++++++++++++++---------- perl-xCAT/xCAT/Usage.pm | 2 + xCAT-client/pods/man1/lsvm.1.pod | 40 +++-- xCAT-client/pods/man1/rspconfig.1.pod | 38 +++++ 5 files changed, 227 insertions(+), 107 deletions(-) diff --git a/perl-xCAT/xCAT/FSPcfg.pm b/perl-xCAT/xCAT/FSPcfg.pm index b3cd2093f..3423865a5 100644 --- a/perl-xCAT/xCAT/FSPcfg.pm +++ b/perl-xCAT/xCAT/FSPcfg.pm @@ -94,7 +94,8 @@ sub parse_args { "pending_power_on_side", "BSR", "setup_failover", - "force_failover" + "force_failover", + "huge_page" ); my @frame = ( "frame", @@ -259,7 +260,7 @@ sub parse_args { return( \%opt ); } if(exists($cmds{sysname}) or exists($cmds{pending_power_on_side}) or exists($cmds{BSR}) - or exists($cmds{setup_failover}) or exists($cmds{force_failover})) { + or exists($cmds{setup_failover}) or exists($cmds{force_failover}) or exists ($cmds{huge_page})) { $request->{hcp} = $request->{hwtype} eq 'frame' ? "bpa":"fsp"; $request->{method} = "do_fspapi_function"; return (\%opt); @@ -342,6 +343,11 @@ sub parse_option { if ($command =~ /^(BSR|force_failover)$/ ) { return ("BSR value can not be set"); } + if ($command =~ /^huge_page$/) { + if ($value !~ /^[0-9]+$/) { + return ("Invalid huge page param '$value'"); + } + } return undef; } sub check_node_info { @@ -396,6 +402,14 @@ my %fspapi_action = ( query => { cec => "cec_force_failover" } + }, + huge_page => { + query => { + cec => "get_huge_page" + }, + set => { + cec => "set_huge_page" + } } ); sub do_process_query_res { @@ -419,7 +433,7 @@ sub do_process_query_res { return "Error"; } } - } elsif ($cmd =~ /^BSR$/) { + } elsif ($cmd =~ /^(BSR|huge_page)$/) { my @values = split(/\n/, @$res[1]); foreach my $v (@values) { push @$result, [$name, $v, '0']; @@ -457,6 +471,8 @@ sub do_set_get_para { return ($value =~ /^perm$/) ? '0' : '1'; } elsif ($cmd =~ /^setup_failover$/) { return ($value =~ /^enable$/) ? '1' : '0'; + } else { + return $value; } } @@ -500,7 +516,7 @@ sub do_fspapi_function { my @ret = (); my $res; my $args = $request->{arg}; - my @fspapi_array = qw/sysname pending_power_on_side BSR setup_failover force_failover/; + my @fspapi_array = qw/sysname pending_power_on_side BSR setup_failover force_failover huge_page/; my $invalid_node = &check_node_info($hash); if (defined($invalid_node)) { return ([[$invalid_node, "Node must be CEC or Frame", '1']]); diff --git a/perl-xCAT/xCAT/FSPvm.pm b/perl-xCAT/xCAT/FSPvm.pm index c7813481b..e9eaf8d51 100644 --- a/perl-xCAT/xCAT/FSPvm.pm +++ b/perl-xCAT/xCAT/FSPvm.pm @@ -4,7 +4,7 @@ BEGIN { $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; } - + package xCAT::FSPvm; use lib "$::XCATROOT/lib/perl"; @@ -47,26 +47,38 @@ sub parse_args { ########################################################################## # Parse the chvm command line for options and operands ########################################################################## -sub chvm_parse_lparname { - my $args = shift; - my $opt = shift; - if ((ref($args) ne 'ARRAY') || - (scalar(@$args) > '1')){ - return "@$args"; - } - my ($cmd, $value) = split(/\=/, $args->[0]); - if ($cmd !~ /^lparname$/) { - return "'$cmd' not support"; - } - if (!defined($value)) { - return "value not specified"; - } - $opt->{$cmd} = $value; - if ($value && $value ne '*' && $value !~ /^[a-zA-Z0-9-_]+$/) { - return "'$value' invalid"; - } - return undef; + +sub chvm_parse_extra_options { + my $args = shift; + my $opt = shift; + if (ref($args) ne 'ARRAY') { + return "$args"; + } + foreach (@$args) { + my ($cmd, $value) = split (/\=/, $_); + if (!defined($value)) { + return "no value specified"; + } + if ($cmd =~ /^lparname$/) { + if ($value ne '*' && $value !~ /^[a-zA-Z0-9-_]$/) { + return "'$value' invalid"; + } + my $len = rindex $value."\$", "\$"; + if ($len > '47') { + return "'$value' is too long, max 47 characters"; + } +# } elsif ($cmd =~ /^huge_page$/) { +# if ($value !~ /^\d+\/\d+\/\d+$/) { +# return "'$value' invalid"; +# } + } else { + return "'$cmd' not support"; + } + $opt->{$cmd} = $value; + } + return undef; } + sub chvm_parse_args { my $request = shift; @@ -294,18 +306,13 @@ sub chvm_parse_args { # Check for an extra argument #################################### if ( defined( $ARGV[0] )) { - my $check_chvm_lpar_arg = chvm_parse_lparname(\@ARGV, \%opt); - if (defined($check_chvm_lpar_arg)) { - return (usage("Invalid argument: $check_chvm_lpar_arg")); + my $check_chvm_arg = chvm_parse_extra_options(\@ARGV, \%opt); + if (defined($check_chvm_arg)) { + return (usage("Invalid argument: $check_chvm_arg")); } elsif (($opt{lparname} ne '*') && (scalar(@{$request->{node}}) > '1')){ return(usage( "Invalid argument: must specify '*' for more than one node" )); - } else { - my $len = rindex $opt{lparname}."\$", "\$"; - if ($len > '47') { - return (usage("Invalid lparname '$opt{lparname}', name is too long, max 47 characters")); - } } - if (exists($opt{lparname}) && + if ((exists($opt{lparname}) ||exists($opt{huge_page})) && (exists($opt{p}) || exists($opt{i}) || exists($opt{r}))) { return (usage("lparname should NOT be used with -p, -i or -r.")); } @@ -617,20 +624,29 @@ sub modify { my $usage_string = xCAT::Usage->getUsage($request->{command}); return modify_by_prof( $request, $hash) if ( $request->{opt}->{p} || $request->{stdin}); return create( $request, $hash) if ( $request->{opt}->{i}); - return op_lparname ($request, $hash) if ($request->{opt}->{lparname}); + return op_extra_cmds ($request, $hash) if ($request->{opt}->{lparname} || $request->{opt}->{huge_page}); return ([["Error", "Miss argument\n".$usage_string, 1]]); } -sub do_set_lparname { +sub do_op_extra_cmds { my $request = shift; my $hash = shift; my @values = (); + my $action; + my $param; + if (exists($request->{opt}->{lparname})) { + $action = "set_lpar_name"; + $param = $request->{opt}->{lparname}; + } elsif (exists($request->{opt}->{huge_page})) { + $action = "set_huge_page"; + $param = $request->{opt}->{huge_page}; + } my $lparname_para = $request->{opt}->{lparname}; while (my ($mtms, $h) = each(%$hash)) { while (my($name, $d) = each(%$h)) { - my $lparname = ($lparname_para eq '*') ? $name : $lparname_para; - my $values = xCAT::FSPUtils::fsp_api_action($name, $d, "set_lpar_name", 0, $lparname); - if (@$values[1] && ((@$values[1] =~ /Error/i) && (@$values[2] ne '0'))) { - return ([[$name, @$values[1], '1']]) ; + my $tmp_value = ($param eq '*') ? $name : $param; + my $value = xCAT::FSPUtils::fsp_api_action($name, $d, $action, 0, $tmp_value); + if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) { + return ([[$name, @$value[1], '1']]) ; } else { push @values, [$name, "Success", '0']; } @@ -653,7 +669,7 @@ sub check_node_info { return $not_lpar; } -sub op_lparname { +sub op_extra_cmds { my $request = shift; my $hash = shift; my $node = $request->{node}; @@ -661,7 +677,7 @@ sub op_lparname { if (defined($lpar_flag)) { return ([[$lpar_flag,"Node must be LPAR", 1]]); } - return &do_set_lparname($request, $hash); + return &do_op_extra_cmds($request, $hash); } @@ -824,25 +840,41 @@ sub enumerate { return( [0,\%outhash] ); } -sub get_cec_lpar_info { - my $name = shift; - my $attr = shift; - my $values = xCAT::FSPUtils::fsp_api_action($name, $attr, "get_lpar_info"); - if (@$values[1] && ((@$values[1] =~ /Error/i) && @$values[2] ne '0')) { - return ([[$name, @$values[1], '1']]); - } - return @$values[1]; -} -sub get_cec_bsr_info { - my $name = shift; - my $attr = shift; - my $values = xCAT::FSPUtils::fsp_api_action($name, $attr, "get_cec_bsr"); +sub get_cec_attr_info { + my $name = shift; + my $attr = shift; + my $op = shift; + my %op_hash = ( + lpar_info => "get_lpar_info", + bsr => "get_cec_bsr", + huge_page => "get_huge_page" + ); + my $action = $op_hash{$op}; + my $values = xCAT::FSPUtils::fsp_api_action($name, $attr, $action); if (@$values[1] && ((@$values[1] =~ /Error/i) && @$values[2] ne '0')) { return ([[$name, @$values[1], '1']]); } return @$values[1]; } +sub get_cec_lpar_hugepage { + my $name = shift; + my $huge_info = shift; + my $lparid = shift; + my $lparname = shift; + my @value = split(/\n/, $huge_info); + foreach my $v (@value) { + if($v =~ /\s*([^\s]+)\s*:\s*([\d|\/]+)/) { + my $tmp_name = $1; + my $tmp_num = $2; + if($tmp_name =~ /^$lparname$/) { + return $tmp_num; + } + } + } + return ([[$name, "can not get huge page info for lpar id $lparid", '1']]); + +} sub get_cec_lpar_name { my $name = shift; @@ -899,16 +931,39 @@ sub get_cec_cec_bsr { return $cec_bsr; } } -sub get_lpar_lpar_name { - my $name = shift; - my $attr = shift; - my $values = xCAT::FSPUtils::fsp_api_action($name, $attr, "get_lpar_name"); - if (@$values[1] && ((@$values[1] =~ /Error/i) && (@$values[2] ne '0'))) { - my @result = (); - push @result, $values; - return \@result; - } - return @$values[1]; +sub get_cec_cec_hugepage { + my $name = shift; + my $huge_info = shift; + my $index = 0; + my @value = split (/\n/, $huge_info); + my $cec_hugepage = ""; + foreach my $v (@value) { + if ($v =~ /(Available huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif($v =~ /(Configurable huge page memory\(in pages\):)\s*(\d+)/i){ + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif($v =~ /(Page Size\(in GB\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif($v =~ /(Maximum huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } elsif($v =~ /(Requested huge page memory\(in pages\):)\s*(\d+)/i) { + my $tmp = sprintf "%-40s %s;\n", $1, $2; + $cec_hugepage .= $tmp; + $index++; + } + } + if ($index != 5) { + return undef; + } + return $cec_hugepage; } ########################################################################## @@ -925,7 +980,8 @@ sub list { my @result; my $lpar_infos; my $bsr_infos; - my $l_string; + my $huge_infos; + my $l_string = "\n"; #print Dumper($hash); while (my ($mtms,$h) = each(%$hash) ) { my $info = enumerate( $h, $mtms ); @@ -954,16 +1010,22 @@ sub list { push @result,[$node_name, $msg, 0]; } else { # get the I/O slot information - if($request->{opt}->{l} and $type =~ /^(fsp|cec)$/) { - $lpar_infos = get_cec_lpar_info($node_name, $d); + if($request->{opt}->{l}) { + if ($type =~ /^(fsp|cec)$/) { + $bsr_infos = get_cec_attr_info($node_name, $d, "bsr"); + if (ref($bsr_infos) eq 'ARRAY') { + return $bsr_infos; + } + } + $lpar_infos = get_cec_attr_info($node_name, $d, "lpar_info"); if (ref($lpar_infos) eq 'ARRAY') { return $lpar_infos; } - $bsr_infos = get_cec_bsr_info($node_name, $d); - if (ref($bsr_infos) eq 'ARRAY') { - return $bsr_infos; - } - } + $huge_infos = get_cec_attr_info($node_name, $d, "huge_page"); + if (ref($huge_infos) eq 'ARRAY') { + return $huge_infos; + } + } my $v; my @t; my @value = split(/\n/, $values); @@ -971,17 +1033,23 @@ sub list { my ($lparid, @t ) = split (/,/, $v); my $ios = join('/', @t); if ($request->{opt}->{l}) { - my $lparname = undef; + my $lparname = get_cec_lpar_name($node_name, $lpar_infos, $lparid); if ($type =~ /^(fsp|cec)$/) { - $lparname = get_cec_lpar_name($node_name, $lpar_infos, $lparid); my $lpar_bsr = get_cec_lpar_bsr($node_name, $bsr_infos, $lparid, $lparname); if (ref($lpar_bsr) eq 'ARRAY') { return $lpar_bsr; } $ios .= ": ".$lpar_bsr; } else { - $lparname = get_lpar_lpar_name($node_name, $d); - } + if ($lparid ne $id) { + next; + } + } + my $hugepage = get_cec_lpar_hugepage($node_name, $huge_infos, $lparid, $lparname); + if (ref($hugepage) eq 'ARRAY') { + return $hugepage; + } + $ios .= ": ".$hugepage; if (ref($lparname) eq 'ARRAY') { return $lparname; } else { @@ -1005,13 +1073,15 @@ sub list { my $value = $data->{$cec}; if ($request->{opt}->{l}) { my $cec_bsr = get_cec_cec_bsr($node_name, $bsr_infos); - $l_string = "\n".$l_string.$value.$cec_bsr; + my $cec_hugepage = get_cec_cec_hugepage($node_name, $huge_infos); + $l_string .= $value.$cec_bsr; + $l_string .= $cec_hugepage; } else { $l_string = $value; } } push @result, [$node_name, $l_string, $Rc]; - $l_string = ""; + $l_string = "\n"; } # end of while }# end of while return( \@result ); @@ -1363,16 +1433,4 @@ sub lsvm { return( list(@_) ); } - - 1; - - - - - - - - - - diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 627ec12bc..b5af5f9d8 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -141,6 +141,8 @@ my %usage = ( rspconfig [pending_power_on_side=] rspconfig [cec_off_policy] rspconfig [cec_off_policy=] + rspconfig [huge_page] + rspconfig [huge_page=] rspconfig [BSR] rspconfig [setup_failover] rspconfig [setup_failover=] diff --git a/xCAT-client/pods/man1/lsvm.1.pod b/xCAT-client/pods/man1/lsvm.1.pod index 9cec4bc9e..03b531483 100644 --- a/xCAT-client/pods/man1/lsvm.1.pod +++ b/xCAT-client/pods/man1/lsvm.1.pod @@ -143,23 +143,23 @@ To list the lparname of lpars, enter: Output is similar to: - lpar1: 1: 514/U78A9.001.0123456-P1-C17/0x21010202/2/1 - lpar1: 1: 513/U78A9.001.0123456-P1-C15/0x21010201/2/1 - lpar1: 1: 512/U78A9.001.0123456-P1-C16/0x21010200/2/1 - lpar13: 13: 537/U78A9.001.0123456-P1-C9/0x21010219/2/13 - lpar13: 13: 536/U78A9.001.0123456-P1-C10/0x21010218/2/13 - lpar17: 17: 545/U78A9.001.0123456-P1-C7/0x21010221/2/17 - lpar17: 17: 544/U78A9.001.0123456-P1-C8/0x21010220/2/17 - lpar21: 21: 553/U78A9.001.0123456-P1-C5/0x21010229/2/21 - lpar21: 21: 552/U78A9.001.0123456-P1-C6/0x21010228/2/21 - lpar24: 25: 569/U78A9.001.0123456-P1-C1/0x21010239/2/25 - lpar25: 25: 561/U78A9.001.0123456-P1-C3/0x21010231/2/25 - lpar25: 25: 560/U78A9.001.0123456-P1-C4/0x21010230/2/25 - lpar29: 29: 568/U78A9.001.0123456-P1-C2/0x21010238/2/29 - lpar5: 5: 521/U78A9.001.0123456-P1-C13/0x21010209/2/5 - lpar5: 5: 520/U78A9.001.0123456-P1-C14/0x21010208/2/5 - lpar9: 9: 529/U78A9.001.0123456-P1-C11/0x21010211/2/9 - lpar9: 9: 528/U78A9.001.0123456-P1-C12/0x21010210/2/9 + lpar1: 1: 514/U78A9.001.0123456-P1-C17/0x21010202/2/1: 32: 0/3/3 + lpar1: 1: 513/U78A9.001.0123456-P1-C15/0x21010201/2/1: 32: 0/3/3 + lpar1: 1: 512/U78A9.001.0123456-P1-C16/0x21010200/2/1: 32: 0/3/3 + lpar13: 13: 537/U78A9.001.0123456-P1-C9/0x21010219/2/13: 32: 0/3/3 + lpar13: 13: 536/U78A9.001.0123456-P1-C10/0x21010218/2/13: 32: 0/3/3 + lpar17: 17: 545/U78A9.001.0123456-P1-C7/0x21010221/2/17: 32: 0/0/0 + lpar17: 17: 544/U78A9.001.0123456-P1-C8/0x21010220/2/17: 32: 0/0/0 + lpar21: 21: 553/U78A9.001.0123456-P1-C5/0x21010229/2/21: 32: 0/0/0 + lpar21: 21: 552/U78A9.001.0123456-P1-C6/0x21010228/2/21: 32: 0/0/0 + lpar24: 25: 569/U78A9.001.0123456-P1-C1/0x21010239/2/25: 32: 0/0/0 + lpar25: 25: 561/U78A9.001.0123456-P1-C3/0x21010231/2/25: 32: 0/0/0 + lpar25: 25: 560/U78A9.001.0123456-P1-C4/0x21010230/2/25: 32: 0/0/0 + lpar29: 29: 568/U78A9.001.0123456-P1-C2/0x21010238/2/29: 32: 0/0/0 + lpar5: 5: 521/U78A9.001.0123456-P1-C13/0x21010209/2/5: 32: 0/3/3 + lpar5: 5: 520/U78A9.001.0123456-P1-C14/0x21010208/2/5: 32: 0/3/3 + lpar9: 9: 529/U78A9.001.0123456-P1-C11/0x21010211/2/9: 32: 0/3/3 + lpar9: 9: 528/U78A9.001.0123456-P1-C12/0x21010210/2/9: 32: 0/3/3 cec1: PendingPumpMode=1,CurrentPumpMode=1,OctantCount=8: OctantID=0,PendingOctCfg=5,CurrentOctCfg=1,PendingMemoryInterleaveMode=2,CurrentMemoryInterleaveMode=2; OctantID=1,PendingOctCfg=1,CurrentOctCfg=1,PendingMemoryInterleaveMode=2,CurrentMemoryInterleaveMode=2; @@ -169,6 +169,12 @@ Output is similar to: OctantID=5,PendingOctCfg=1,CurrentOctCfg=1,PendingMemoryInterleaveMode=2,CurrentMemoryInterleaveMode=2; OctantID=6,PendingOctCfg=1,CurrentOctCfg=1,PendingMemoryInterleaveMode=2,CurrentMemoryInterleaveMode=2; OctantID=7,PendingOctCfg=1,CurrentOctCfg=1,PendingMemoryInterleaveMode=2,CurrentMemoryInterleaveMode=2; + Number of BSR arrays: 256,Bytes per BSR array: 4096,Available BSR array: 0; + Available huge page memory(in pages): 0 + Configurable huge page memory(in pages): 12 + Page Size(in GB): 16 + Maximum huge page memory(in pages): 24 + Requested huge page memory(in pages): 15 =head1 FILES diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 6f5915538..0dc6484f7 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -140,6 +140,10 @@ B I B={B|B} B I {B} +B I {B} + +B I B={B} + B I {B} B I B={B|B} @@ -260,6 +264,10 @@ Display the CEC/BPA system names. Get Barrier Synchronization Register (BSR) allocation for a CEC. +=item B + +Query huge page information or request NUM of huge pages for CEC. If no value specified, it means query huge page information for the specified CECs, if a CEC is specified, the specified huge_page value NUM will be used as the requested number of huge pages for the CEC, if CECs are specified, it means to request the same NUM huge pages for all the specified CECs. + =item B={I|I} Enable or disable the service processor failover function of a CEC or display status of this function. @@ -629,6 +637,36 @@ B I =item * +To query the huge page information for CEC1, enter: + +B I + + CEC1: Huge Page Memory + CEC1: Available huge page memory(in pages): 0 + CEC1: Configurable huge page memory(in pages): 12 + CEC1: Page Size (in GB): 16 + CEC1: Maximum huge page memory(in pages): 24 + CEC1: Requested huge page memory(in pages): 15 + CEC1: Partition name: Huge pages + CEC1: lpar1 : 3 + CEC1: lpar5 : 3 + CEC1: lpar9 : 3 + CEC1: lpar13 : 3 + CEC1: lpar17 : 0 + CEC1: lpar21 : 0 + CEC1: lpar25 : 0 + CEC1: lpar29 : 0 + +=item * + +To request 10 huge pages for CEC1, enter: + +B I + + CEC1: Success + +=item * + To disable service processor failover for cec01, in order to complete this command, the user should power off cec01 first: B I