From mboxrd@z Thu Jan 1 00:00:00 1970 From: Don Slutz Subject: Re: [PATCH] numa.c: use spaces instead of tabs Date: Sat, 06 Sep 2014 13:28:41 -0400 Message-ID: <540B4449.1000606@terremark.com> References: <1409717890-2837-1-git-send-email-ufimtseva@gmail.com> <1409737969.2673.35.camel@Solace.lan> <54070330020000780003029A@mail.emea.novell.com> <540725DE0200007800030453@mail.emea.novell.com> <5407286C02000078000304B5@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------070603030402000603000705" Return-path: In-Reply-To: <5407286C02000078000304B5@mail.emea.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 Fraser , Ian Campbell , George Dunlap , Dario Faggioli , Ian Jackson , "xen-devel@lists.xen.org" , Elena Ufimtseva List-Id: xen-devel@lists.xenproject.org This is a multi-part message in MIME format. --------------070603030402000603000705 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit On 09/03/14 08:40, Jan Beulich wrote: >>>> On 03.09.14 at 14:34, wrote: >> I understand that, but that style is mixed. Not linux, not Xen :) > Yeah, mistakes like that creep in. But we're trying to avoid them > (perhaps harder now than a few years ago). > > Jan I have attempted to get Xen coding style (not libxl coding style) into a more automated process. Using astyle (Artistic Style Version 2.04), the attached astyle options file does a lot of the work. dcs-xen-54:~/xen>astyle --options=/home/don/xen.astylerc xen/arch/x86/hvm/vmware/vmport_rpc.c Formatted xen/arch/x86/hvm/vmware/vmport_rpc.c dcs-xen-54:~/xen>emacs -nw /home/don/xen_reformat.el xen/arch/x86/hvm/vmware/vmport_rpc.c However it does not support the: Space characters are used to spread out logical statements, ... And so I use the emacs extension xen-reformat-region (also attached) to post process the file, and adjust to the Xen style. This only works if the emacs local variables comment (See CODING_STYLE) is there. Using this on xen/arch/x86/numa.c (and asking git to ignore white space changes) gives me: dcs-xen-54:~/xen>git diff -w diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 628a40a..35ce32c 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -35,13 +35,15 @@ static typeof(*memnodemap) _memnodemap[64]; unsigned long memnodemapsize; u8 *memnodemap; -unsigned char cpu_to_node[NR_CPUS] __read_mostly = { +unsigned char cpu_to_node[NR_CPUS] __read_mostly = +{ [0 ... NR_CPUS - 1] = NUMA_NO_NODE }; /* * Keep BIOS's CPU2node information, should not be used for memory allocaion */ -unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = { +unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = +{ [0 ... MAX_LOCAL_APIC - 1] = NUMA_NO_NODE }; cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly; @@ -413,7 +415,8 @@ static void dump_numa(unsigned char key) rcu_read_unlock(&domlist_read_lock); } -static struct keyhandler dump_numa_keyhandler = { +static struct keyhandler dump_numa_keyhandler = +{ .diagnostic = 1, .u.fn = dump_numa, .desc = "dump numa info" @@ -426,3 +429,11 @@ static __init int register_numa_trigger(void) } __initcall(register_numa_trigger); +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ The attached zz.txt file the full git diff output. If there are coding styles left I would like to know about them. -Don Slutz > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------070603030402000603000705 Content-Type: text/plain; charset=us-ascii; name="xen.astylerc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen.astylerc" # # Default is mostly allman / ansi / bsd / break # style=bsd # # Converts tabs into single spaces. # convert-tabs # # indent using spaces by 4 # indent=spaces=4 # # Do preprocessor statements also. # indent-preproc-define # # Insert space padding around operators only. # pad-oper # # Insert space padding after paren headers only. # pad-header # # Remove extra space padding around parenthesis on the inside and outside. # unpad-paren # # Remove brackets from 1 line conditional statements. # remove-brackets # # Attach a pointer or reference operator to variable name # align-pointer=name # # Do not change the reference alignment. # align-reference=none # # The option max-code-length will break a line # max-code-length=80 # # Set the minimal indent that is added when a header is built of multiple lines. # min-conditional-indent=0 --------------070603030402000603000705 Content-Type: text/x-emacs-lisp; name="xen_reformat.el" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="xen_reformat.el" (defun xen-reformat-region () "Adjust region based on xen/CODING_STYLE." (interactive "") (save-excursion (let ((start (point)) (end (mark)) (case-fold-search nil) ) (if (not end) (setq end (point-max)) ) (if (< end start) (progn (setq start (mark)) (setq end (point)) ) ) (goto-char start) (while (word-search-forward "if" end t) (if (looking-at "(") (insert-char ? 1) ) (if (looking-at " ") (just-one-space) ) (if (looking-at "(") (progn (forward-char) (insert-char ? 1) (just-one-space) (backward-char 2) (forward-sexp) (backward-char 1) (insert-char ? 1) (just-one-space) ) ) ) (goto-char start) (while (word-search-forward "while" end t) (if (looking-at "(") (insert-char ? 1) ) (if (looking-at " ") (just-one-space) ) (if (looking-at "(") (progn (forward-char) (insert-char ? 1) (just-one-space) (backward-char 2) (forward-sexp) (backward-char 1) (insert-char ? 1) (just-one-space) ) ) ) (goto-char start) (while (word-search-forward "for" end t) (if (looking-at "(") (insert-char ? 1) ) (if (looking-at " ") (just-one-space) ) (if (looking-at "(") (progn (forward-char) (insert-char ? 1) (just-one-space) (backward-char 2) (forward-sexp) (backward-char 1) (insert-char ? 1) (just-one-space) ) ) ) (goto-char start) (while (word-search-forward "switch" end t) (if (looking-at "(") (insert-char ? 1) ) (if (looking-at " ") (just-one-space) ) (if (looking-at "(") (progn (forward-char) (insert-char ? 1) (just-one-space) (backward-char 2) (forward-sexp) (backward-char 1) (insert-char ? 1) (just-one-space) ) ) ) (goto-char start) (while (word-search-forward "do" end t) (if (eolp) (delete-char 1) ) (if (looking-at "(") (insert-char ? 1) ) (if (looking-at " ") (just-one-space) ) (if (looking-at "{") (progn (forward-sexp) (if (eolp) (delete-char 1) ) (insert-char ? 1) (just-one-space) ) ) ) (indent-region start end) (untabify start end) ) ) ) --------------070603030402000603000705 Content-Type: text/plain; charset=us-ascii; name="zz.txt" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="zz.txt" diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c index 628a40a..35ce32c 100644 --- a/xen/arch/x86/numa.c +++ b/xen/arch/x86/numa.c @@ -1,8 +1,8 @@ -/* +/* * Generic VM initialization for x86-64 NUMA setups. * Copyright 2002,2003 Andi Kleen, SuSE Labs. * Adapted for Xen: Ryan Harper - */ + */ #include #include @@ -35,14 +35,16 @@ static typeof(*memnodemap) _memnodemap[64]; unsigned long memnodemapsize; u8 *memnodemap; -unsigned char cpu_to_node[NR_CPUS] __read_mostly = { - [0 ... NR_CPUS-1] = NUMA_NO_NODE +unsigned char cpu_to_node[NR_CPUS] __read_mostly = +{ + [0 ... NR_CPUS - 1] = NUMA_NO_NODE }; /* * Keep BIOS's CPU2node information, should not be used for memory allocaion */ -unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = { - [0 ... MAX_LOCAL_APIC-1] = NUMA_NO_NODE +unsigned char apicid_to_node[MAX_LOCAL_APIC] __cpuinitdata = +{ + [0 ... MAX_LOCAL_APIC - 1] = NUMA_NO_NODE }; cpumask_t node_to_cpumask[MAX_NUMNODES] __read_mostly; @@ -144,7 +146,7 @@ static int __init extract_lsb_from_nodes(const struct node *nodes, if ( nodes_used <= 1 ) i = BITS_PER_LONG - 1; else - i = find_first_bit(&bitfield, sizeof(unsigned long)*8); + i = find_first_bit(&bitfield, sizeof(unsigned long) * 8); memnodemapsize = (memtop >> i) + 1; return i; } @@ -173,7 +175,7 @@ int __init compute_hash_shift(struct node *nodes, int numnodes, } /* initialize NODE_DATA given nodeid and start/end */ void __init setup_node_bootmem(int nodeid, u64 start, u64 end) -{ +{ unsigned long start_pfn, end_pfn; start_pfn = start >> PAGE_SHIFT; @@ -184,7 +186,7 @@ void __init setup_node_bootmem(int nodeid, u64 start, u64 end) NODE_DATA(nodeid)->node_spanned_pages = end_pfn - start_pfn; node_set_online(nodeid); -} +} void __init numa_init_array(void) { @@ -215,7 +217,7 @@ static int __init numa_emulation(u64 start_pfn, u64 end_pfn) { int i; struct node nodes[MAX_NUMNODES]; - u64 sz = ((end_pfn - start_pfn)< 1 ) @@ -223,17 +225,17 @@ static int __init numa_emulation(u64 start_pfn, u64 end_pfn) u64 x = 1; while ( (x << 1) < sz ) x <<= 1; - if ( x < sz/2 ) + if ( x < sz / 2 ) printk(KERN_ERR "Numa emulation unbalanced. Complain to maintainer\n"); sz = x; } - memset(&nodes,0,sizeof(nodes)); + memset(&nodes, 0, sizeof(nodes)); for ( i = 0; i < numa_fake; i++ ) { - nodes[i].start = (start_pfn< dumping numa info (now-0x%X:%08X)\n", key, - (u32)(now>>32), (u32)now); + (u32)(now >> 32), (u32)now); - for_each_online_node ( i ) + for_each_online_node(i) { - paddr_t pa = (paddr_t)(NODE_DATA(i)->node_start_pfn + 1)<< PAGE_SHIFT; + paddr_t pa = (paddr_t)(NODE_DATA(i)->node_start_pfn + 1) << PAGE_SHIFT; printk("idx%d -> NODE%d start->%lu size->%lu free->%lu\n", i, NODE_DATA(i)->node_id, NODE_DATA(i)->node_start_pfn, @@ -385,17 +387,17 @@ static void dump_numa(unsigned char key) NODE_DATA(i)->node_id); } - for_each_online_cpu ( i ) + for_each_online_cpu(i) printk("CPU%d -> NODE%d\n", i, cpu_to_node[i]); rcu_read_lock(&domlist_read_lock); printk("Memory location of each domain:\n"); - for_each_domain ( d ) + for_each_domain(d) { printk("Domain %u (total: %u):\n", d->domain_id, d->tot_pages); - for_each_online_node ( i ) + for_each_online_node(i) page_num_node[i] = 0; spin_lock(&d->page_alloc_lock); @@ -406,14 +408,15 @@ static void dump_numa(unsigned char key) } spin_unlock(&d->page_alloc_lock); - for_each_online_node ( i ) + for_each_online_node(i) printk(" Node %u: %u\n", i, page_num_node[i]); } rcu_read_unlock(&domlist_read_lock); } -static struct keyhandler dump_numa_keyhandler = { +static struct keyhandler dump_numa_keyhandler = +{ .diagnostic = 1, .u.fn = dump_numa, .desc = "dump numa info" @@ -426,3 +429,11 @@ static __init int register_numa_trigger(void) } __initcall(register_numa_trigger); +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ --------------070603030402000603000705 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --------------070603030402000603000705--