Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752057AbdFLBnX (ORCPT ); Sun, 11 Jun 2017 21:43:23 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:39372 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751936AbdFLBnW (ORCPT ); Sun, 11 Jun 2017 21:43:22 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com Date: Mon, 12 Jun 2017 10:43:08 +0900 From: Byungchul Park To: Juri Lelli Cc: peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, juri.lelli@gmail.com, rostedt@goodmis.org, kernel-team@lge.com Subject: Re: [PATCH 2/2] sched/deadline: Don't return invalid cpu in cpudl_maximum_cpu() Message-ID: <20170612014307.GH3623@X58A-UD3R> References: <1496388663-29067-1-git-send-email-byungchul.park@lge.com> <1496388663-29067-2-git-send-email-byungchul.park@lge.com> <20170606151225.xlhrnh2usajmlu52@e106622-lin> <20170606234224.GD3623@X58A-UD3R> <20170607001454.GE3623@X58A-UD3R> <20170608140243.omvx62ivewtofk75@e106622-lin> <20170609024327.GG3623@X58A-UD3R> <20170609114206.jy7hyr6xnmwwipg5@e106622-lin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170609114206.jy7hyr6xnmwwipg5@e106622-lin> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1590 Lines: 41 On Fri, Jun 09, 2017 at 12:42:06PM +0100, Juri Lelli wrote: > > > > This would also work and avoid unnecessary warning. I missed the check > > to avoid it. https://lkml.org/lkml/2017/3/23/175 was an original patch > > doing it. > > > > By the way, frankly speaking, I don't like accessing the cpudl instant > > several times without protection. I rather prefer the following.. > > > > But whatever. I like both. > > > > Thnaks, > > Byungchul > > > > ----->8----- > > diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c > > index 9b314a9..1d369cf 100644 > > --- a/kernel/sched/cpudeadline.c > > +++ b/kernel/sched/cpudeadline.c > > @@ -137,11 +137,17 @@ int cpudl_find(struct cpudl *cp, struct task_struct *p, > > cpumask_and(later_mask, cp->free_cpus, &p->cpus_allowed)) { > > best_cpu = cpumask_any(later_mask); > > goto out; > > - } else if (cpumask_test_cpu(cpudl_maximum_cpu(cp), &p->cpus_allowed) && > > - dl_time_before(dl_se->deadline, cpudl_maximum_dl(cp))) { > > - best_cpu = cpudl_maximum_cpu(cp); > > - if (later_mask) > > - cpumask_set_cpu(best_cpu, later_mask); > > + } else { > > + int max_cpu = cpudl_maximum_cpu(cp); > > + u64 max_dl = cpudl_maximum_dl(cp); > > + > > + if (max_cpu != -1 && > > + cpumask_test_cpu(max_cpu, &p->cpus_allowed) && > > + dl_time_before(dl_se->deadline, max_dl)) { > > Don't we access cp 3 times both ways? I wonder if I miss something.. As you said, in most cases it will, but I am not sure if we can guarentee that, regardless of arches or compile optimization level. Sorry if I am wrong.