Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933527AbdCWKdm (ORCPT ); Thu, 23 Mar 2017 06:33:42 -0400 Received: from LGEAMRELO13.lge.com ([156.147.23.53]:50644 "EHLO lgeamrelo13.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932910AbdCWKdW (ORCPT ); Thu, 23 Mar 2017 06:33:22 -0400 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 165.244.249.23 X-Original-MAILFROM: byungchul.park@lge.com X-Original-SENDERIP: 10.177.222.33 X-Original-MAILFROM: byungchul.park@lge.com From: Byungchul Park To: , CC: , , , Subject: [PATCH 2/8] sched/deadline: Re-define parameters of cpudl heapify functions Date: Thu, 23 Mar 2017 19:32:37 +0900 Message-ID: <1490265163-29981-3-git-send-email-byungchul.park@lge.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> References: <1490265163-29981-1-git-send-email-byungchul.park@lge.com> X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:18, Serialize by Router on LGEKRMHUB01/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2017/03/23 19:33:18, Serialize complete at 2017/03/23 19:33:18 MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4727 Lines: 157 If you don't like this clean-up patch, please let me know. If so, I will exclude this patch from next spin. Thank you, Byungchul -----8<----- >From b303ccf6b64064ce22aa17d16a012dcc7904ad32 Mon Sep 17 00:00:00 2001 From: Byungchul Park Date: Wed, 22 Mar 2017 14:07:22 +0900 Subject: [PATCH 2/8] sched/deadline: Re-define parameters of cpudl heapify functions Currently whole 'struct cpudl' is used as a parameter on heapifying. However, only elements and size are needed on the work. So change the parameters. Signed-off-by: Byungchul Park --- kernel/sched/cpudeadline.c | 63 ++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c index fba235c..7dd6d9d 100644 --- a/kernel/sched/cpudeadline.c +++ b/kernel/sched/cpudeadline.c @@ -31,14 +31,14 @@ static inline int right_child(int i) return (i << 1) + 2; } -static void cpudl_heapify_down(struct cpudl *cp, int idx) +static void cpudl_heapify_down(struct cpudl_item *e, int size, int idx) { int l, r, largest; - int orig_cpu = cp->elements[idx].cpu; - u64 orig_dl = cp->elements[idx].dl; + int orig_cpu = e[idx].cpu; + u64 orig_dl = e[idx].dl; - if (left_child(idx) >= cp->size) + if (left_child(idx) >= size) return; /* adapted from lib/prio_heap.c */ @@ -49,63 +49,60 @@ static void cpudl_heapify_down(struct cpudl *cp, int idx) largest = idx; largest_dl = orig_dl; - if ((l < cp->size) && dl_time_before(orig_dl, - cp->elements[l].dl)) { + if ((l < size) && dl_time_before(orig_dl, e[l].dl)) { largest = l; - largest_dl = cp->elements[l].dl; + largest_dl = e[l].dl; } - if ((r < cp->size) && dl_time_before(largest_dl, - cp->elements[r].dl)) + if ((r < size) && dl_time_before(largest_dl, e[r].dl)) largest = r; if (largest == idx) break; /* pull largest child onto idx */ - cp->elements[idx].cpu = cp->elements[largest].cpu; - cp->elements[idx].dl = cp->elements[largest].dl; - cp->elements[cp->elements[idx].cpu].idx = idx; + e[idx].cpu = e[largest].cpu; + e[idx].dl = e[largest].dl; + e[e[idx].cpu].idx = idx; idx = largest; } /* actual push down of saved original values orig_* */ - cp->elements[idx].cpu = orig_cpu; - cp->elements[idx].dl = orig_dl; - cp->elements[cp->elements[idx].cpu].idx = idx; + e[idx].cpu = orig_cpu; + e[idx].dl = orig_dl; + e[e[idx].cpu].idx = idx; } -static void cpudl_heapify_up(struct cpudl *cp, int idx) +static void cpudl_heapify_up(struct cpudl_item *e, int size, int idx) { int p; - int orig_cpu = cp->elements[idx].cpu; - u64 orig_dl = cp->elements[idx].dl; + int orig_cpu = e[idx].cpu; + u64 orig_dl = e[idx].dl; if (idx == 0) return; do { p = parent(idx); - if (dl_time_before(orig_dl, cp->elements[p].dl)) + if (dl_time_before(orig_dl, e[p].dl)) break; /* pull parent onto idx */ - cp->elements[idx].cpu = cp->elements[p].cpu; - cp->elements[idx].dl = cp->elements[p].dl; - cp->elements[cp->elements[idx].cpu].idx = idx; + e[idx].cpu = e[p].cpu; + e[idx].dl = e[p].dl; + e[e[idx].cpu].idx = idx; idx = p; } while (idx != 0); /* actual push up of saved original values orig_* */ - cp->elements[idx].cpu = orig_cpu; - cp->elements[idx].dl = orig_dl; - cp->elements[cp->elements[idx].cpu].idx = idx; + e[idx].cpu = orig_cpu; + e[idx].dl = orig_dl; + e[e[idx].cpu].idx = idx; } -static void cpudl_heapify(struct cpudl *cp, int idx) +static void cpudl_heapify(struct cpudl_item *e, int size, int idx) { - if (idx > 0 && dl_time_before(cp->elements[parent(idx)].dl, - cp->elements[idx].dl)) - cpudl_heapify_up(cp, idx); + if (idx > 0 && dl_time_before(e[parent(idx)].dl, e[idx].dl)) + cpudl_heapify_up(e, size, idx); else - cpudl_heapify_down(cp, idx); + cpudl_heapify_down(e, size, idx); } static inline int cpudl_maximum(struct cpudl *cp) @@ -176,7 +173,7 @@ void cpudl_clear(struct cpudl *cp, int cpu) cp->size--; cp->elements[new_cpu].idx = old_idx; cp->elements[cpu].idx = IDX_INVALID; - cpudl_heapify(cp, old_idx); + cpudl_heapify(cp->elements, cp->size, old_idx); cpumask_set_cpu(cpu, cp->free_cpus); } @@ -208,11 +205,11 @@ void cpudl_set(struct cpudl *cp, int cpu, u64 dl) cp->elements[new_idx].dl = dl; cp->elements[new_idx].cpu = cpu; cp->elements[cpu].idx = new_idx; - cpudl_heapify_up(cp, new_idx); + cpudl_heapify_up(cp->elements, cp->size, new_idx); cpumask_clear_cpu(cpu, cp->free_cpus); } else { cp->elements[old_idx].dl = dl; - cpudl_heapify(cp, old_idx); + cpudl_heapify(cp->elements, cp->size, old_idx); } raw_spin_unlock_irqrestore(&cp->lock, flags); -- 1.9.1