From patchwork Thu Jan 23 11:15:34 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 23614 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 67F6D203BE for ; Thu, 23 Jan 2014 11:15:45 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id m10sf2744025vbh.0 for ; Thu, 23 Jan 2014 03:15:44 -0800 (PST) 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:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=yBkbrFawkHW1lr8/Wa/RAsq3oudWP2y2wPu//69cvnM=; b=fDH+0WSDT4xR4IcYVLgo0/Y9xmmN06DuMO94S3XE6MvbqQIOLWuxBl/73dWPjpKVV5 G8dTIodrin3A1jbqAigE1xI5C13Zb0hxegVEfHLQpuK4TVMNmvP5SSGMabQIdy8h/8ty S1BF7TFqrv6vsG1mOktLjdbfA+1Wx8xl3+iQTo/GYLOb3Hr43UPyiS1Qa5X1i0p7el7c CzVELGgUXXRhV6PsJP6NL8TMX7LQom0a/6wffzHZM1Y155fj2bcjT3kl1690fkNjbmsu 7mLHJoOajh1tz6fX/GeZ4CEkK4XCFWFYP95yuEcj6dAqpiU6F01hmFCHqd/URXp9ltFn iZAQ== X-Gm-Message-State: ALoCoQmHsb31iJmEe7os/2zpOPzAI1/oPb0G5cOrQaW3bri8zjSm8Y7xuc0M7ZuqwOyf2XL/zueq X-Received: by 10.236.145.34 with SMTP id o22mr2538250yhj.22.1390475744582; Thu, 23 Jan 2014 03:15:44 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.25.198 with SMTP id 64ls312157qgt.31.gmail; Thu, 23 Jan 2014 03:15:44 -0800 (PST) X-Received: by 10.59.5.102 with SMTP id cl6mr43627ved.41.1390475744489; Thu, 23 Jan 2014 03:15:44 -0800 (PST) Received: from mail-vb0-f48.google.com (mail-vb0-f48.google.com [209.85.212.48]) by mx.google.com with ESMTPS id w5si6480151vcn.101.2014.01.23.03.15.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 03:15:44 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.48 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.48; Received: by mail-vb0-f48.google.com with SMTP id q16so955177vbe.35 for ; Thu, 23 Jan 2014 03:15:44 -0800 (PST) X-Received: by 10.58.226.163 with SMTP id rt3mr4295925vec.34.1390475744404; Thu, 23 Jan 2014 03:15:44 -0800 (PST) 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 u4csp18382vcz; Thu, 23 Jan 2014 03:15:43 -0800 (PST) X-Received: by 10.180.37.162 with SMTP id z2mr7302771wij.51.1390475743529; Thu, 23 Jan 2014 03:15:43 -0800 (PST) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id lm2si8855739wjb.40.2014.01.23.03.15.43 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 03:15:43 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.174 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id x55so962723wes.5 for ; Thu, 23 Jan 2014 03:15:43 -0800 (PST) X-Received: by 10.180.80.103 with SMTP id q7mr24323478wix.14.1390475742775; Thu, 23 Jan 2014 03:15:42 -0800 (PST) Received: from localhost ([213.122.173.131]) by mx.google.com with ESMTPSA id pl7sm21507917wjc.16.2014.01.23.03.15.39 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 23 Jan 2014 03:15:41 -0800 (PST) From: Viresh Kumar To: mingo@kernel.org, peterz@infradead.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH] cpusets: Allocate heap only when required Date: Thu, 23 Jan 2014 16:45:34 +0530 Message-Id: <8622e93b9c49c66ffdc9ef0aa8371c322718edd5.1390475530.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e 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.212.48 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: , update_flag() routine uses heap only when spread_flag_changed is true. Otherwise heap isn't used, but is allocated and freed unnecessarily. Fix this by allocating heap only when required. Signed-off-by: Viresh Kumar --- Rebased over linux-next/master kernel/cpuset.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 4410ac6..9ccdfb2 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c @@ -1326,16 +1326,18 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, if (err < 0) goto out; - err = heap_init(&heap, PAGE_SIZE, GFP_KERNEL, NULL); - if (err < 0) - goto out; - balance_flag_changed = (is_sched_load_balance(cs) != is_sched_load_balance(trialcs)); spread_flag_changed = ((is_spread_slab(cs) != is_spread_slab(trialcs)) || (is_spread_page(cs) != is_spread_page(trialcs))); + if (spread_flag_changed) { + err = heap_init(&heap, PAGE_SIZE, GFP_KERNEL, NULL); + if (err < 0) + goto out; + } + mutex_lock(&callback_mutex); cs->flags = trialcs->flags; mutex_unlock(&callback_mutex); @@ -1343,9 +1345,10 @@ static int update_flag(cpuset_flagbits_t bit, struct cpuset *cs, if (!cpumask_empty(trialcs->cpus_allowed) && balance_flag_changed) rebuild_sched_domains_locked(); - if (spread_flag_changed) + if (spread_flag_changed) { update_tasks_flags(cs, &heap); - heap_free(&heap); + heap_free(&heap); + } out: free_trial_cpuset(trialcs); return err;