From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v4 1/7] x86: detect and initialize Cache QoS Monitoring feature Date: Tue, 3 Dec 2013 13:45:44 +0000 Message-ID: <529DE088.7070507@citrix.com> References: <1386060479-17205-1-git-send-email-dongxiao.xu@intel.com> <1386060479-17205-2-git-send-email-dongxiao.xu@intel.com> <529DC4A5.4000603@citrix.com> <529DE28302000078001095F1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <529DE28302000078001095F1@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: keir@xen.org, Ian.Campbell@citrix.com, stefano.stabellini@eu.citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, Dongxiao Xu , dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 03/12/13 12:54, Jan Beulich wrote: >>>> On 03.12.13 at 12:46, Andrew Cooper wrote: >> This currently won't do what you expect, and to get regular Xen boolean >> behaviour, you need tobe a little more cunning. >> >> Here is some completely untested code... >> >> static void __init parse_pqos_param(char *s) >> { >> char *ss; >> char *val_str; >> int val; >> >> do { >> val = !!strncmp(s, "no-", 3); >> if ( !val ) >> s += 3; >> >> ss = strchr(s, ','); >> if ( ss ) >> *ss = '\0'; >> >> val_str = strchr(s, '='); >> >> if ( !parse_bool(s) ) >> opt_pqos = 0; > This won't either - parse_bool() returns the boolean value, or > negative if the input didn't match any of the boolean tokens. > > Also, while I realize that you likely took this from elsewhere, I > think we should stop further propagation of bad things (like > allowing "pqos=no-true" or "pqos=no-cqm=on"). > > And using = for both the top level separator and the sub-option > ones looks odd to me generally too. I'd suggest using : instead. > > Jan > Hmm yes - perhaps that would be better, and more in line with the current options such as dom0_mem So something like this? static void __init parse_pqos_param(char *s) { char *ss, *val_str; int val; do { val = !!strncmp(s, "no-", 3); if ( !val ) s += 3; ss = strchr(s, ','); if ( ss ) *ss = '\0'; val_str = strchr(s, ':'); if ( !parse_bool(s) ) opt_pqos = 0; else if ( !strcmp(s, "cqm") ) opt_cqm = val; else if ( val_str && !strcmp(s, "cqm_max_rmid") ) opt_cqm_max_rmid = simple_strtoul(val_str, NULL, 0); s = ss + 1; } while ( ss ); } ~Andrew