Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261375AbVCKXK5 (ORCPT ); Fri, 11 Mar 2005 18:10:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S261823AbVCKXHh (ORCPT ); Fri, 11 Mar 2005 18:07:37 -0500 Received: from fire.osdl.org ([65.172.181.4]:7630 "EHLO smtp.osdl.org") by vger.kernel.org with ESMTP id S261866AbVCKWzy (ORCPT ); Fri, 11 Mar 2005 17:55:54 -0500 Date: Fri, 11 Mar 2005 14:52:26 -0800 From: Andrew Morton To: Christoph Lameter Cc: davej@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH] mm counter operations through macros Message-Id: <20050311145226.6ee4a951.akpm@osdl.org> In-Reply-To: References: <20050311182500.GA4185@redhat.com> X-Mailer: Sylpheed version 1.0.0 (GTK+ 1.2.10; i386-vine-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2095 Lines: 53 Christoph Lameter wrote: > > This patch extracts all the operations on counters protected by the > page table lock (currently rss and anon_rss) into definitions in > include/linux/sched.h. All rss operations are performed through > the following macros: > > get_mm_counter(mm, member) -> Obtain the value of a counter > set_mm_counter(mm, member, value) -> Set the value of a counter > update_mm_counter(mm, member, value) -> Add to a counter > inc_mm_counter(mm, member) -> Increment a counter > dec_mm_counter(mm, member) -> Decrement a counter I spose it makes sense, if we'll be making scalability changes in there. > > +#define set_mm_counter(mm, member, value) (mm)->member = (value) > +#define get_mm_counter(mm, member) ((mm)->member) > +#define update_mm_counter(mm, member, value) (mm)->member += (value) > +#define inc_mm_counter(mm, member) (mm)->member++ > +#define dec_mm_counter(mm, member) (mm)->member-- > +#define MM_COUNTER_T unsigned long Would prefer `mm_counter_t' here. Why not a typedef? > @@ -231,9 +237,13 @@ struct mm_struct { > unsigned long start_code, end_code, start_data, end_data; > unsigned long start_brk, brk, start_stack; > unsigned long arg_start, arg_end, env_start, env_end; > - unsigned long rss, anon_rss, total_vm, locked_vm, shared_vm; > + unsigned long total_vm, locked_vm, shared_vm; > unsigned long exec_vm, stack_vm, reserved_vm, def_flags, nr_ptes; > > + /* Special counters protected by the page_table_lock */ > + MM_COUNTER_T rss; > + MM_COUNTER_T anon_rss; > + Why were only two counters converted? Could I suggest that you rename all these counters, so that code which fails to use the macros won't compile? That renaming can be hidden in the header file: add an underscore to the front of all the identifiers, paste that underscore back within the macros. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/