From: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: kosaki.motohiro@jp.fujitsu.com,
Marcelo Tosatti <marcelo@kvack.org>,
Daniel Spang <daniel.spang@gmail.com>,
Rik van Riel <riel@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: [RFC][PATCH 1/8] mem_notify v5: introduce poll_wait_exclusive() new API
Date: Thu, 24 Jan 2008 13:19:25 +0900 [thread overview]
Message-ID: <20080124131817.1763.KOSAKI.MOTOHIRO@jp.fujitsu.com> (raw)
In-Reply-To: <20080124130348.1760.KOSAKI.MOTOHIRO@jp.fujitsu.com>
There are 2 way of adding item to wait_queue,
1. add_wait_queue()
2. add_wait_queue_exclusive()
and add_wait_queue_exclusive() is very useful API.
unforunately, poll_wait_exclusive() against poll_wait() doesn't exist.
it means there is no way that wake up only 1 process where polled.
wake_up() is wake up all sleeping process by poll_wait(), not 1 process.
this patch introduce poll_wait_exclusive() new API for allow wake up only 1 process.
<example of usage>
unsigned int kosaki_poll(struct file *file,
struct poll_table_struct *wait)
{
poll_wait_exclusive(file, &kosaki_wait_queue, wait);
if (data_exist)
return POLLIN | POLLRDNORM;
return 0;
}
Signed-off-by: Marcelo Tosatti <marcelo@kvack.org>
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
---
fs/eventpoll.c | 7 +++++--
fs/select.c | 9 ++++++---
include/linux/poll.h | 11 +++++++++--
3 files changed, 20 insertions(+), 7 deletions(-)
Index: linux-2.6.24-rc6-mm1-memnotify/fs/eventpoll.c
===================================================================
--- linux-2.6.24-rc6-mm1-memnotify.orig/fs/eventpoll.c 2008-01-17 18:28:15.000000000 +0900
+++ linux-2.6.24-rc6-mm1-memnotify/fs/eventpoll.c 2008-01-17 18:55:47.000000000 +0900
@@ -675,7 +675,7 @@ out_unlock:
* target file wakeup lists.
*/
static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead,
- poll_table *pt)
+ poll_table *pt, int exclusive)
{
struct epitem *epi = ep_item_from_epqueue(pt);
struct eppoll_entry *pwq;
@@ -684,7 +684,10 @@ static void ep_ptable_queue_proc(struct
init_waitqueue_func_entry(&pwq->wait, ep_poll_callback);
pwq->whead = whead;
pwq->base = epi;
- add_wait_queue(whead, &pwq->wait);
+ if (exclusive)
+ add_wait_queue_exclusive(whead, &pwq->wait);
+ else
+ add_wait_queue(whead, &pwq->wait);
list_add_tail(&pwq->llink, &epi->pwqlist);
epi->nwait++;
} else {
Index: linux-2.6.24-rc6-mm1-memnotify/fs/select.c
===================================================================
--- linux-2.6.24-rc6-mm1-memnotify.orig/fs/select.c 2008-01-17 18:28:23.000000000 +0900
+++ linux-2.6.24-rc6-mm1-memnotify/fs/select.c 2008-01-17 18:55:47.000000000 +0900
@@ -48,7 +48,7 @@ struct poll_table_page {
* poll table.
*/
static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
- poll_table *p);
+ poll_table *p, int exclusive);
void poll_initwait(struct poll_wqueues *pwq)
{
@@ -117,7 +117,7 @@ static struct poll_table_entry *poll_get
/* Add a new entry */
static void __pollwait(struct file *filp, wait_queue_head_t *wait_address,
- poll_table *p)
+ poll_table *p, int exclusive)
{
struct poll_table_entry *entry = poll_get_entry(p);
if (!entry)
@@ -126,7 +126,10 @@ static void __pollwait(struct file *filp
entry->filp = filp;
entry->wait_address = wait_address;
init_waitqueue_entry(&entry->wait, current);
- add_wait_queue(wait_address, &entry->wait);
+ if (exclusive)
+ add_wait_queue_exclusive(wait_address, &entry->wait);
+ else
+ add_wait_queue(wait_address, &entry->wait);
}
#define FDS_IN(fds, n) (fds->in + n)
Index: linux-2.6.24-rc6-mm1-memnotify/include/linux/poll.h
===================================================================
--- linux-2.6.24-rc6-mm1-memnotify.orig/include/linux/poll.h 2008-01-17 18:28:32.000000000 +0900
+++ linux-2.6.24-rc6-mm1-memnotify/include/linux/poll.h 2008-01-17 18:55:47.000000000 +0900
@@ -28,7 +28,8 @@ struct poll_table_struct;
/*
* structures and helpers for f_op->poll implementations
*/
-typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *);
+typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *,
+ struct poll_table_struct *, int);
typedef struct poll_table_struct {
poll_queue_proc qproc;
@@ -37,7 +38,13 @@ typedef struct poll_table_struct {
static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p)
{
if (p && wait_address)
- p->qproc(filp, wait_address, p);
+ p->qproc(filp, wait_address, p, 0);
+}
+
+static inline void poll_wait_exclusive(struct file *filp, wait_queue_head_t *wait_address, poll_table *p)
+{
+ if (p && wait_address)
+ p->qproc(filp, wait_address, p, 1);
}
static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2008-01-24 4:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-24 4:18 [RFC][PATCH 0/8] mem_notify v5 KOSAKI Motohiro
2008-01-24 4:19 ` KOSAKI Motohiro [this message]
2008-01-24 4:20 ` [RFC][PATCH 2/8] mem_notify v5: introduce wake_up_locked_nr() new API KOSAKI Motohiro
2008-01-24 4:21 ` [RFC][PATCH 3/8] mem_notify v5: introduce /dev/mem_notify new device (the core of this patch series) KOSAKI Motohiro
2008-01-24 12:19 ` Daniel Spång
2008-01-25 3:33 ` KOSAKI Motohiro
2008-01-24 4:22 ` [RFC][PATCH 4/8] mem_notify v5: memory_pressure_notify() caller KOSAKI Motohiro
2008-01-24 4:22 ` [RFC][PATCH 5/8] mem_notify v5: add new mem_notify field to /proc/zoneinfo KOSAKI Motohiro
2008-01-24 4:23 ` [RFC][PATCH 6/8] mem_notify v5: (optional) fixed incorrect shrink_zone KOSAKI Motohiro
2008-01-24 4:24 ` [RFC][PATCH 7/8] mem_notify v5: ignore very small zone for prevent incorrect low mem notify KOSAKI Motohiro
2008-01-24 4:26 ` [RFC][PATCH 8/8] mem_notify v5: support fasync feature KOSAKI Motohiro
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=20080124131817.1763.KOSAKI.MOTOHIRO@jp.fujitsu.com \
--to=kosaki.motohiro@jp.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=daniel.spang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=marcelo@kvack.org \
--cc=riel@redhat.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox