From: Joonsoo Kim <js1304@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org,
"Android Kernel Team" <kernel-team@android.com>,
"Joonsoo Kim" <js1304@gmail.com>,
"John Stultz" <john.stultz@linaro.org>,
"Brian Swetland" <swetland@google.com>,
"Colin Cross" <ccross@android.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Dima Zavin" <dima@android.com>, "Robert Love" <rlove@google.com>
Subject: [RFC PATCH] staging, android, ashmem: invalidate pin/unpin ioctl for private map
Date: Sat, 1 Dec 2012 02:45:57 +0900 [thread overview]
Message-ID: <1354297557-24486-1-git-send-email-js1304@gmail.com> (raw)
Private mapped ashmem doesn't install vm fault handler.
So, do_anonymous_page is called for handling fault in handle_pte_fault().
This type of backed memory isn't related to asma->file which is used by
ashmem shrinker. Shrinking unpinned area for this mapping
will not shrink memory actually.
Although it's memory doesn't actually removed, pin status will
return ASHMEM_WAS_PURGED. So application will re-load content.
This is needless overhead, so invalidate pin/unpin ioctl behavior for
private map.
CC: John Stultz <john.stultz@linaro.org>
CC: Brian Swetland <swetland@google.com>
CC: Colin Cross <ccross@android.com>
CC: Arve Hjønnevåg <arve@android.com>
CC: Dima Zavin <dima@android.com>
CC: Robert Love <rlove@google.com>
Signed-off-by: Joonsoo Kim <js1304@gmail.com>
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 634b9ae..2fde9df 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -49,6 +49,7 @@ struct ashmem_area {
struct file *file; /* the shmem-based backing file */
size_t size; /* size of the mapping, in bytes */
unsigned long prot_mask; /* allowed prot bits, as vm_flags */
+ bool shared_mapping; /* mapping type */
};
/*
@@ -327,6 +328,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
fput(asma->file);
goto out;
}
+ asma->shared_mapping = 1;
}
if (vma->vm_file)
@@ -614,21 +616,35 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
pgstart = pin.offset / PAGE_SIZE;
pgend = pgstart + (pin.len / PAGE_SIZE) - 1;
- mutex_lock(&ashmem_mutex);
+ if (asma->shared_mapping) {
+ mutex_lock(&ashmem_mutex);
- switch (cmd) {
- case ASHMEM_PIN:
- ret = ashmem_pin(asma, pgstart, pgend);
- break;
- case ASHMEM_UNPIN:
- ret = ashmem_unpin(asma, pgstart, pgend);
- break;
- case ASHMEM_GET_PIN_STATUS:
- ret = ashmem_get_pin_status(asma, pgstart, pgend);
- break;
- }
+ switch (cmd) {
+ case ASHMEM_PIN:
+ ret = ashmem_pin(asma, pgstart, pgend);
+ break;
+ case ASHMEM_UNPIN:
+ ret = ashmem_unpin(asma, pgstart, pgend);
+ break;
+ case ASHMEM_GET_PIN_STATUS:
+ ret = ashmem_get_pin_status(asma, pgstart, pgend);
+ break;
+ }
- mutex_unlock(&ashmem_mutex);
+ mutex_unlock(&ashmem_mutex);
+
+ } else {
+ switch (cmd) {
+ /* if it is private map, pin/unpin have no impact to vm */
+ case ASHMEM_PIN:
+ case ASHMEM_UNPIN:
+ ret = ASHMEM_NOT_PURGED;
+ break;
+ case ASHMEM_GET_PIN_STATUS:
+ ret = ASHMEM_IS_PINNED;
+ break;
+ }
+ }
return ret;
}
--
1.7.9.5
next reply other threads:[~2012-11-30 17:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-30 17:45 Joonsoo Kim [this message]
2012-12-01 18:39 ` [RFC PATCH] staging, android, ashmem: invalidate pin/unpin ioctl for private map Dan Carpenter
2012-12-03 0:09 ` JoonSoo Kim
2012-12-03 7:31 ` Dan Carpenter
2012-12-03 14:52 ` JoonSoo Kim
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=1354297557-24486-1-git-send-email-js1304@gmail.com \
--to=js1304@gmail.com \
--cc=arve@android.com \
--cc=ccross@android.com \
--cc=devel@driverdev.osuosl.org \
--cc=dima@android.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.stultz@linaro.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rlove@google.com \
--cc=swetland@google.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