From patchwork Sun Sep 22 01:21:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20518 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qc0-f198.google.com (mail-qc0-f198.google.com [209.85.216.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B966225E85 for ; Sun, 22 Sep 2013 01:23:08 +0000 (UTC) Received: by mail-qc0-f198.google.com with SMTP id l13sf1905985qcy.9 for ; Sat, 21 Sep 2013 18:23:08 -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=RExLaUECADoXOWpccBmR8kn4mxeaxlhLlvYQxoyuYtk=; b=CTDJCPhBOzssYBdatUe719U1q3KPlpK2tjUvsObz/9H+aY3hG0rQ+EZJOuFNCFLckF FcSOYzZY7ByHyZFmaRdAFqWAkM/hNqQUApI8vfzJxBsweWU76tNLvpb3FRq4pTgShokQ Z+qHcrK9CtlSLSpy6p3M+MadKAPchd4ILwLaUJIRL4bO9sSwWLEGUuzJYdHCWudlcnoL Lnse8H4tRf/gAT+KUCOCGAYQB396yXeXV2Qi8xgetO9B//AxZmYdAgBb59EfFQoP1jyi dfASL+d9T2um/rC0n1o2ChH+9v94Jt/0KzmvvFnN5RBbgYmBuqglFrQ+AVj0qedyaQo8 GLJA== X-Gm-Message-State: ALoCoQljceLn8U98W9ms4KuOgsCeFM+R2sWp6NgpIg8PA1GAQlpCK48hXMZd/IHG0pKvFR8Fkbg8 X-Received: by 10.224.2.68 with SMTP id 4mr6637749qai.1.1379812988597; Sat, 21 Sep 2013 18:23:08 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.49.196 with SMTP id w4ls712524qen.71.gmail; Sat, 21 Sep 2013 18:23:08 -0700 (PDT) X-Received: by 10.52.116.74 with SMTP id ju10mr11856220vdb.20.1379812988508; Sat, 21 Sep 2013 18:23:08 -0700 (PDT) Received: from mail-ve0-f171.google.com (mail-ve0-f171.google.com [209.85.128.171]) by mx.google.com with ESMTPS id z6si4542356vcu.70.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:08 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.171 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.171; Received: by mail-ve0-f171.google.com with SMTP id pa12so1492525veb.30 for ; Sat, 21 Sep 2013 18:23:08 -0700 (PDT) X-Received: by 10.52.33.44 with SMTP id o12mr7905196vdi.7.1379812988426; Sat, 21 Sep 2013 18:23:08 -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 u4csp91754vcz; Sat, 21 Sep 2013 18:23:07 -0700 (PDT) X-Received: by 10.68.13.104 with SMTP id g8mr16272516pbc.33.1379812987538; Sat, 21 Sep 2013 18:23:07 -0700 (PDT) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id h1si5702822paw.220.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:07 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id v10so1826170pde.24 for ; Sat, 21 Sep 2013 18:23:07 -0700 (PDT) X-Received: by 10.66.162.136 with SMTP id ya8mr16738984pab.110.1379812987147; Sat, 21 Sep 2013 18:23:07 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id ys4sm24682321pbb.9.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 21 Sep 2013 18:23:06 -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 16/21] cpuidle: avoid unnecessary kzalloc/free of struct cpuidle_device_kobj Date: Sun, 22 Sep 2013 06:51:08 +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.171 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: , We always need to allocate struct cpuidle_device_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_device_kobj inside struct cpuidle_device instead of a pointer. Signed-off-by: Viresh Kumar --- drivers/cpuidle/sysfs.c | 24 +++++------------------- include/linux/cpuidle.h | 11 +++++++++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index ade31a9..db0aac3 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -172,12 +172,6 @@ struct cpuidle_attr { #define attr_to_cpuidleattr(a) container_of(a, struct cpuidle_attr, attr) -struct cpuidle_device_kobj { - struct cpuidle_device *dev; - struct completion kobj_unregister; - struct kobject kobj; -}; - static inline struct cpuidle_device *to_cpuidle_device(struct kobject *kobj) { struct cpuidle_device_kobj *kdev = @@ -399,7 +393,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device *device) { int i, ret = -ENOMEM; struct cpuidle_state_kobj *kobj; - struct cpuidle_device_kobj *kdev = device->kobj_dev; + struct cpuidle_device_kobj *kdev = &device->kobj_dev; struct cpuidle_driver *drv = cpuidle_get_cpu_driver(device); /* state statistics */ @@ -525,7 +519,7 @@ static struct kobj_type ktype_driver_cpuidle = { static int cpuidle_add_driver_sysfs(struct cpuidle_device *dev) { struct cpuidle_driver_kobj *kdrv; - struct cpuidle_device_kobj *kdev = dev->kobj_dev; + struct cpuidle_device_kobj *kdev = &dev->kobj_dev; struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); int ret; @@ -606,24 +600,17 @@ void cpuidle_remove_device_sysfs(struct cpuidle_device *device) */ int cpuidle_add_sysfs(struct cpuidle_device *dev) { - struct cpuidle_device_kobj *kdev; + struct cpuidle_device_kobj *kdev = &dev->kobj_dev; struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu); int error; - kdev = kzalloc(sizeof(*kdev), GFP_KERNEL); - if (!kdev) - return -ENOMEM; kdev->dev = dev; - dev->kobj_dev = kdev; - init_completion(&kdev->kobj_unregister); error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, &cpu_dev->kobj, "cpuidle"); - if (error) { - kfree(kdev); + if (error) return error; - } kobject_uevent(&kdev->kobj, KOBJ_ADD); @@ -636,9 +623,8 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev) */ void cpuidle_remove_sysfs(struct cpuidle_device *dev) { - struct cpuidle_device_kobj *kdev = dev->kobj_dev; + struct cpuidle_device_kobj *kdev = &dev->kobj_dev; kobject_put(&kdev->kobj); wait_for_completion(&kdev->kobj_unregister); - kfree(kdev); } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index c082425..1fc5cb5 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -11,6 +11,8 @@ #ifndef _LINUX_CPUIDLE_H #define _LINUX_CPUIDLE_H +#include +#include #include #include #include @@ -59,10 +61,15 @@ struct cpuidle_state { #define CPUIDLE_DRIVER_FLAGS_MASK (0xFFFF0000) -struct cpuidle_device_kobj; struct cpuidle_state_kobj; struct cpuidle_driver_kobj; +struct cpuidle_device_kobj { + struct cpuidle_device *dev; + struct completion kobj_unregister; + struct kobject kobj; +}; + struct cpuidle_device { unsigned int registered:1; unsigned int enabled:1; @@ -73,7 +80,7 @@ struct cpuidle_device { struct cpuidle_state_usage states_usage[CPUIDLE_STATE_MAX]; struct cpuidle_state_kobj *kobjs[CPUIDLE_STATE_MAX]; struct cpuidle_driver_kobj *kobj_driver; - struct cpuidle_device_kobj *kobj_dev; + struct cpuidle_device_kobj kobj_dev; struct list_head device_list; #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED