From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752911AbbJTSPv (ORCPT ); Tue, 20 Oct 2015 14:15:51 -0400 Received: from g2t4622.austin.hp.com ([15.73.212.79]:33752 "EHLO g2t4622.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752812AbbJTSPu (ORCPT ); Tue, 20 Oct 2015 14:15:50 -0400 Message-ID: <1445364945.7547.6.camel@j-VirtualBox> Subject: Re: [PATCH] posix-cpu-timers: Merge running and checking_timer state in one field From: Jason Low To: Frederic Weisbecker Cc: Thomas Gleixner , LKML , George Spelvin , Peter Zijlstra , Davidlohr Bueso , Oleg Nesterov , "Paul E . McKenney" , Jason Low , Ingo Molnar , jason.low2@hp.com Date: Tue, 20 Oct 2015 11:15:45 -0700 In-Reply-To: <1445300334-25977-1-git-send-email-fweisbec@gmail.com> References: <1445300334-25977-1-git-send-email-fweisbec@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2015-10-20 at 02:18 +0200, Frederic Weisbecker wrote: > This way we might consume less space in the signal struct (well, > depending on bool size or padding) and we don't need to worry about > ordering between the running and checking_timers fields. This looks fine to me. I ended up going with booleans since I thought that makes the code more readable, but this method would be okay too. I do have 1 question below. > +/* struct thread_group_cputimer::state bits */ > +#define CPUTIMER_STATE_RUNNING 1 > +#define CPUTIMER_STATE_CHECKING 2 > + > /** > * struct thread_group_cputimer - thread group interval timer counts > * @cputime_atomic: atomic thread group interval timers. > - * @running: true when there are timers running and > - * @cputime_atomic receives updates. > - * @checking_timer: true when a thread in the group is in the > - * process of checking for thread group timers. > - * > + * @state: flags describing the current state of the cputimer. > + * CPUTIMER_STATE_RUNNING bit means the timers is elapsing. > + * CPUTIMER_STATE_CHECKING bit means that the cputimer has > + * expired and a thread in the group is checking the > + * callback list. > * This structure contains the version of task_cputime, above, that is > * used for thread group CPU timer calculations. > */ > struct thread_group_cputimer { > - struct task_cputime_atomic cputime_atomic; > - bool running; > - bool checking_timer; > + struct task_cputime_atomic cputime_atomic; > + unsigned int state; Here are we actually increasing the overhead from 2 bytes -> 4 bytes? If we want to use less space, I was thinking 'unsigned char'.