All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: linux-kernel@vger.kernel.org
Cc: akpm@linux-foundation.org, aarcange@redhat.com,
	andreslc@google.com, aneesh.kumar@linux.vnet.ibm.com,
	cl@gentwo.org, dave.hansen@intel.com, hughd@google.com,
	jmarchan@redhat.com, kirill.shutemov@linux.intel.com,
	n-horiguchi@ah.jp.nec.com, neha.agbk@gmail.com,
	peterz@infradead.org, quning@gmail.com, sasha.levin@oracle.com,
	vbabka@suse.cz, yang.shi@linaro.org, mm-commits@vger.kernel.org
Subject: Re: + thp-extract-khugepaged-from-mm-huge_memoryc-fix.patch added to -mm tree
Date: Thu, 9 Jun 2016 01:57:55 +0300	[thread overview]
Message-ID: <20160608225755.GA8541@node> (raw)
In-Reply-To: <57589435.aDEnsv9WxDX8df1c%akpm@linux-foundation.org>

On Wed, Jun 08, 2016 at 02:55:01PM -0700, akpm@linux-foundation.org wrote:
> 
> The patch titled
>      Subject: thp-extract-khugepaged-from-mm-huge_memoryc-fix
> has been added to the -mm tree.  Its filename is
>      thp-extract-khugepaged-from-mm-huge_memoryc-fix.patch
> 
> This patch should soon appear at
>     http://ozlabs.org/~akpm/mmots/broken-out/thp-extract-khugepaged-from-mm-huge_memoryc-fix.patch
> and later at
>     http://ozlabs.org/~akpm/mmotm/broken-out/thp-extract-khugepaged-from-mm-huge_memoryc-fix.patch
> 
> Before you just go and hit "reply", please:
>    a) Consider who else should be cc'ed
>    b) Prefer to cc a suitable mailing list as well
>    c) Ideally: find the original patch on the mailing list and do a
>       reply-to-all to that, adding suitable additional cc's
> 
> *** Remember to use Documentation/SubmitChecklist when testing your code ***
> 
> The -mm tree is included into linux-next and is updated
> there every 3-4 working days
> 
> ------------------------------------------------------
> From: Andrew Morton <akpm@linux-foundation.org>
> Subject: thp-extract-khugepaged-from-mm-huge_memoryc-fix
> 
> khugepaged_mutex can be static to mm/huge_memory.c:enabled_store()
> 
> Makes me wonder what it actually does...

IIUC, it protects khugepaged_thread.

What about something like this:

diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h
index f7b4b7dc97bc..1e032a1ddb3e 100644
--- a/include/linux/khugepaged.h
+++ b/include/linux/khugepaged.h
@@ -4,7 +4,6 @@
 #include <linux/sched.h> /* MMF_VM_HUGEPAGE */
 
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
-extern struct mutex khugepaged_mutex;
 extern struct attribute_group khugepaged_attr_group;
 
 extern int khugepaged_init(void);
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index eaf3a4a655a6..522cf178f118 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -181,12 +181,7 @@ static ssize_t enabled_store(struct kobject *kobj,
 				TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG);
 
 	if (ret > 0) {
-		int err;
-
-		mutex_lock(&khugepaged_mutex);
-		err = start_stop_khugepaged();
-		mutex_unlock(&khugepaged_mutex);
-
+		int err = start_stop_khugepaged();
 		if (err)
 			ret = err;
 	}
diff --git a/mm/khugepaged.c b/mm/khugepaged.c
index 71a6f9bedfdc..6f5815488c6c 100644
--- a/mm/khugepaged.c
+++ b/mm/khugepaged.c
@@ -58,8 +58,6 @@ static unsigned int khugepaged_scan_sleep_millisecs __read_mostly = 10000;
 /* during fragmentation poll the hugepage allocator once every minute */
 static unsigned int khugepaged_alloc_sleep_millisecs __read_mostly = 60000;
 static unsigned long khugepaged_sleep_expire;
-static struct task_struct *khugepaged_thread __read_mostly;
-DEFINE_MUTEX(khugepaged_mutex);
 static DEFINE_SPINLOCK(khugepaged_mm_lock);
 static DECLARE_WAIT_QUEUE_HEAD(khugepaged_wait);
 /*
@@ -1885,7 +1883,11 @@ static void set_recommended_min_free_kbytes(void)
 
 int start_stop_khugepaged(void)
 {
+	static struct task_struct *khugepaged_thread __read_mostly;
+	static DEFINE_MUTEX(khugepaged_mutex);
 	int err = 0;
+
+	mutex_lock(&khugepaged_mutex);
 	if (khugepaged_enabled()) {
 		if (!khugepaged_thread)
 			khugepaged_thread = kthread_run(khugepaged, NULL,
@@ -1906,5 +1908,6 @@ int start_stop_khugepaged(void)
 		khugepaged_thread = NULL;
 	}
 fail:
+	mutex_unlock(&khugepaged_mutex);
 	return err;
 }
-- 
 Kirill A. Shutemov

      reply	other threads:[~2016-06-08 22:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08 21:55 + thp-extract-khugepaged-from-mm-huge_memoryc-fix.patch added to -mm tree akpm
2016-06-08 22:57 ` Kirill A. Shutemov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160608225755.GA8541@node \
    --to=kirill@shutemov.name \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreslc@google.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=cl@gentwo.org \
    --cc=dave.hansen@intel.com \
    --cc=hughd@google.com \
    --cc=jmarchan@redhat.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=n-horiguchi@ah.jp.nec.com \
    --cc=neha.agbk@gmail.com \
    --cc=peterz@infradead.org \
    --cc=quning@gmail.com \
    --cc=sasha.levin@oracle.com \
    --cc=vbabka@suse.cz \
    --cc=yang.shi@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.