From patchwork Sun Sep 22 01:21:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20519 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f70.google.com (mail-qe0-f70.google.com [209.85.128.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6BEB325E85 for ; Sun, 22 Sep 2013 01:23:15 +0000 (UTC) Received: by mail-qe0-f70.google.com with SMTP id b4sf1936700qen.9 for ; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=f7iLZaaM6Qrk5PrFzj+/NrYfF5Zx266GShyYc0Ghjdg=; b=izJH6LhVvxhs3fYMiv89QAoxSXI6Dl4u05qCMVeoPSsIC5NFA1d7pNEIZMbbZDr1jl v0/Y2OyqLdKq5OFnYNqztqML7OZUpbM3Ct/VuurDPOBE6J7QU3KwSlI8FWvI/WcGv3Be 7k/9bTrpO2zyN+i/8wLO6C8fWEIbEnp7vL2a/twSkB19qruSZ15vzXjyjpS45HCWXIYV 5JAGq4iIY+u+OkOphMeMbtlgzbieqYp/VdGw78qpuEY8glJYFtnmREo9y118htP9tWpd 8Xwv2HJakOXIKpIcx3KgbQ0pAxqhA/VnAs6usKddz2JcMaGpuOx+11pjTYm2wEwYs2Dz QGRw== X-Gm-Message-State: ALoCoQleGKfbs6RmA25EkcKkwiBgC7g/623g4NxAjST0FTLIv5apUerv7nVxjMgpRYhwr8ev20Fu X-Received: by 10.236.207.103 with SMTP id m67mr5209412yho.1.1379812995286; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.116.228 with SMTP id jz4ls745536qeb.51.gmail; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) X-Received: by 10.220.1.203 with SMTP id 11mr14094253vcg.15.1379812995172; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id gq10si4516647vdc.147.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jw12so1496275veb.9 for ; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) X-Received: by 10.52.116.74 with SMTP id ju10mr11856505vdb.20.1379812995055; Sat, 21 Sep 2013 18:23:15 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp91758vcz; Sat, 21 Sep 2013 18:23:14 -0700 (PDT) X-Received: by 10.66.191.137 with SMTP id gy9mr71532pac.147.1379812993979; Sat, 21 Sep 2013 18:23:13 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id jx3si15842318pbc.144.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:13 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.50; Received: by mail-pb0-f50.google.com with SMTP id uo5so1821318pbc.37 for ; Sat, 21 Sep 2013 18:23:13 -0700 (PDT) X-Received: by 10.67.30.70 with SMTP id kc6mr16794704pad.32.1379812993572; Sat, 21 Sep 2013 18:23:13 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id tg7sm24623969pbc.36.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:13 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, daniel.lezcano@linaro.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH 17/21] cpuidle: avoid unnecessary kzalloc/free of struct cpuidle_driver_kobj Date: Sun, 22 Sep 2013 06:51:09 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , For CONFIG_CPU_IDLE_MULTIPLE_DRIVERS, struct cpuidle_device always needs to allocate struct cpuidle_driver_kobj for all CPUs and so there is no real need to have a pointer to it inside struct cpuidle_device. This patch makes a object instance of struct cpuidle_driver_kobj inside struct cpuidle_device instead of a pointer. It also makes kobj_driver dependent on CONFIG_CPU_IDLE_MULTIPLE_DRIVERS. Signed-off-by: Viresh Kumar --- drivers/cpuidle/sysfs.c | 20 +++----------------- include/linux/cpuidle.h | 11 +++++++++-- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index db0aac3..3386d64 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -439,12 +439,6 @@ static void cpuidle_remove_state_sysfs(struct cpuidle_device *device) static struct cpuidle_driver_attr attr_driver_##_name = \ __ATTR(_name, 0644, show, NULL) -struct cpuidle_driver_kobj { - struct cpuidle_driver *drv; - struct completion kobj_unregister; - struct kobject kobj; -}; - struct cpuidle_driver_attr { struct attribute attr; ssize_t (*show)(struct cpuidle_driver *, char *); @@ -518,27 +512,20 @@ static struct kobj_type ktype_driver_cpuidle = { */ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) { - struct cpuidle_driver_kobj *kdrv; + struct cpuidle_driver_kobj *kdrv = &dev->kobj_driver; struct cpuidle_device_kobj *kdev = &dev->kobj_dev; struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int ret; - kdrv = kzalloc(sizeof(*kdrv), GFP_KERNEL); - if (!kdrv) - return -ENOMEM; - kdrv->drv = drv; init_completion(&kdrv->kobj_unregister); ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle, &kdev->kobj, "driver"); - if (ret) { - kfree(kdrv); + if (ret) return ret; - } kobject_uevent(&kdrv->kobj, KOBJ_ADD); - dev->kobj_driver = kdrv; return ret; } @@ -549,10 +536,9 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) */ static void cpuidle_remove_driver_sysfs(struct cpuidle_device *dev) { - struct cpuidle_driver_kobj *kdrv = dev->kobj_driver; + struct cpuidle_driver_kobj *kdrv = &dev->kobj_driver; kobject_put(&kdrv->kobj); wait_for_completion(&kdrv->kobj_unregister); - kfree(kdrv); } #else static inline int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index 1fc5cb5..0f0da17 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -62,7 +62,6 @@ struct cpuidle_state { #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) struct cpuidle_state_kobj; -struct cpuidle_driver_kobj; struct cpuidle_device_kobj { struct cpuidle_device *dev; @@ -70,6 +69,12 @@ struct cpuidle_device_kobj { struct kobject kobj; }; +struct cpuidle_driver_kobj { + struct cpuidle_driver *drv; + struct completion kobj_unregister; + struct kobject kobj; +}; + struct cpuidle_device { unsigned int registered:1; unsigned int enabled:1; @@ -79,7 +84,9 @@ struct cpuidle_device { int state_count; struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; - struct cpuidle_driver_kobj *kobj_driver; +#ifdef CONFIG_CPU_IDLE_MULTIPLE_DRIVERS + struct cpuidle_driver_kobj kobj_driver; +#endif struct cpuidle_device_kobj kobj_dev; struct list_head device_list;