From patchwork Wed Sep 25 23:22:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 2945721 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 16103BFF05 for ; Wed, 25 Sep 2013 23:27:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3BCDB2011B for ; Wed, 25 Sep 2013 23:27:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A5C820353 for ; Wed, 25 Sep 2013 23:27:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755836Ab3IYX0q (ORCPT ); Wed, 25 Sep 2013 19:26:46 -0400 Received: from e23smtp08.au.ibm.com ([202.81.31.141]:45119 "EHLO e23smtp08.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756445Ab3IYX0o (ORCPT ); Wed, 25 Sep 2013 19:26:44 -0400 Received: from /spool/local by e23smtp08.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Sep 2013 09:26:42 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp08.au.ibm.com (202.81.31.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Sep 2013 09:26:39 +1000 Received: from d23relay05.au.ibm.com (d23relay05.au.ibm.com [9.190.235.152]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 551843578050; Thu, 26 Sep 2013 09:26:39 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r8PN9ocw10092988; Thu, 26 Sep 2013 09:09:50 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id r8PNQah8026581; Thu, 26 Sep 2013 09:26:38 +1000 Received: from srivatsabhat.in.ibm.com ([9.79.250.85]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id r8PNQRM8026447; Thu, 26 Sep 2013 09:26:29 +1000 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v4 38/40] mm: Add a mechanism to queue work to the kmempowerd kthread To: akpm@linux-foundation.org, mgorman@suse.de, dave@sr71.net, hannes@cmpxchg.org, tony.luck@intel.com, matthew.garrett@nebula.com, riel@redhat.com, arjan@linux.intel.com, srinivas.pandruvada@linux.intel.com, willy@linux.intel.com, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, paulmck@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com, andi@firstfloor.org, isimatu.yasuaki@jp.fujitsu.com, santosh.shilimkar@ti.com, kosaki.motohiro@gmail.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Thu, 26 Sep 2013 04:52:26 +0530 Message-ID: <20130925232224.26184.9597.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130925231250.26184.31438.stgit@srivatsabhat.in.ibm.com> References: <20130925231250.26184.31438.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13092523-5140-0000-0000-000003E4193E Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,KHOP_BIG_TO_CC, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we have a dedicated kthread in place to perform targeted region evacuation, add and export a mechanism to queue work to the kthread. Adding work to kmempowerd is very simple: just set the bits corresponding to the region numbers that we want to evacuate, and queue the work item to the kthread. Signed-off-by: Srivatsa S. Bhat --- mm/compaction.c | 26 ++++++++++++++++++++++++++ mm/internal.h | 3 +++ 2 files changed, 29 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/mm/compaction.c b/mm/compaction.c index 0511eae..b56be89 100644 --- a/mm/compaction.c +++ b/mm/compaction.c @@ -1271,6 +1271,32 @@ int evacuate_mem_region(struct zone *z, struct zone_mem_region *zmr) #define nr_zone_region_bits MAX_NR_ZONE_REGIONS static DECLARE_BITMAP(mpwork_mask, nr_zone_region_bits); +void queue_mempower_work(struct pglist_data *pgdat, struct zone *zone, + int region_id) +{ + struct mempower_work *mpwork; + unsigned long flags; + + mpwork = &zone->mempower_work; + spin_lock_irqsave(&mpwork->lock, flags); + set_bit(region_id, mpwork->mempower_mask); + spin_unlock_irqrestore(&mpwork->lock, flags); + + /* + * The kmempowerd kthread will never miss the work we assign it, + * due to the way queue_kthread_work() and kthread_worker_fn() + * synchronize with each other. If the work is currently executing, + * it gets requeued; but if it is pending, the kthread will naturally + * process it in the future. Eitherway, it will notice and process + * all the work submitted to it, and won't prematurely go to sleep. + * + * Note: The bits set in the mempower_mask represent the actual + * "work" for the kthread. The work-struct is just a container used + * to communicate that work to the kthread. + */ + queue_kthread_work(&pgdat->mempower_worker, &mpwork->work); +} + static void kmempowerd(struct kthread_work *work) { struct mempower_work *mpwork; diff --git a/mm/internal.h b/mm/internal.h index acb50f8..3fbc9f6 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -181,6 +181,9 @@ int compact_range(struct compact_control *cc, struct aggression_control *ac, struct free_page_control *fc, unsigned long start, unsigned long end); +void queue_mempower_work(struct pglist_data *pgdat, struct zone *zone, + int region_id); + #endif /*