Le Tuesday 08 Oct 2019 à 15:34:04 (+0100), Valentin Schneider a écrit :
> On 08/10/2019 15:16, Peter Zijlstra wrote:
> > On Wed, Oct 02, 2019 at 11:47:59AM +0100, Valentin Schneider wrote:
> > 
> >> Yeah, right shift on signed negative values are implementation defined.
> > 
> > Seriously? Even under -fno-strict-overflow? There is a perfectly
> > sensible operation for signed shift right, this stuff should not be
> > undefined.
> > 
> 
> Mmm good point. I didn't see anything relevant in the description of that
> flag. All my copy of the C99 standard (draft) says at 6.5.7.5 is:
> 
> """
> The result of E1 >> E2 [...] If E1 has a signed type and a negative value,
> the resulting value is implementation-defined.
> """
> 
> Arithmetic shift would make sense, but I think this stems from twos'
> complement not being imposed: 6.2.6.2.2 says sign can be done with
> sign + magnitude, twos complement or ones' complement...
> 
> I suppose when you really just want a division you should ask for division
> semantics - i.e. use '/'. I'd expect compilers to be smart enough to turn
> that into a shift if a power of 2 is involved, and to do something else
> if negative values can be involved.

This is how I plan to get ride of the problem:
+               if (busiest->group_weight == 1 || sds->prefer_sibling) {
+                       unsigned int nr_diff = busiest->sum_h_nr_running;
+                       /*
+                        * When prefer sibling, evenly spread running tasks on
+                        * groups.
+                        */
+                       env->migration_type = migrate_task;
+                       lsub_positive(&nr_diff, local->sum_h_nr_running);
+                       env->imbalance = nr_diff >> 1;
+                       return;
+               }

Reply via email to