[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAO6Zf6D4bgQrpLhT3nzwim_PFzhiB0wzH77Coj04APgHfkSMCQ@mail.gmail.com>
Date: Sat, 17 Mar 2012 17:21:48 +0100
From: Dmitry Adamushko <dmitry.adamushko@...il.com>
To: John Stultz <john.stultz@...aro.org>
Cc: linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Android Kernel Team <kernel-team@...roid.com>,
Robert Love <rlove@...gle.com>, Mel Gorman <mel@....ul.ie>,
Hugh Dickins <hughd@...gle.com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Rik van Riel <riel@...hat.com>,
Dave Chinner <david@...morbit.com>, Neil Brown <neilb@...e.de>,
Andrea Righi <andrea@...terlinux.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>
Subject: Re: [PATCH 2/2] [RFC] fadvise: Add _VOLATILE,_ISVOLATILE, and
_NONVOLATILE flags
Hi John,
[ ... ]
> +/*
> + * Mark a region as volatile, allowing dirty pages to be purged
> + * under memory pressure
> + */
> +long mapping_range_volatile(struct address_space *mapping,
> + pgoff_t start_index, pgoff_t end_index)
> +{
> + struct volatile_range *new;
> + struct range_tree_node *node;
> +
> + u64 start, end;
> + int purged = 0;
> + start = (u64)start_index;
> + end = (u64)end_index;
> +
> + new = vrange_alloc();
> + if (!new)
> + return -ENOMEM;
> +
> + mutex_lock(&volatile_mutex);
> +
> + node = range_tree_in_range_adjacent(&mapping->volatile_root,
> + start, end);
> + while (node) {
> + struct volatile_range *vrange;
> +
> + /* Already entirely marked volatile, so we're done */
> + if (node->start < start && node->end > end) {
> + /* don't need the allocated value */
> + kfree(new);
> + goto out;
> + }
> +
> + /* Grab containing volatile range */
> + vrange = container_of(node, struct volatile_range, range_node);
> +
> + /* resize range */
> + start = min_t(u64, start, node->start);
> + end = max_t(u64, end, node->end);
> + purged |= vrange->purged;
> +
> +
> + vrange_del(vrange);
> +
> + /* get the next possible overlap */
> + node = range_tree_in_range(&mapping->volatile_root, start, end);
I guess range_tree_in_range_adjacent() should be used here again.
There can be 2 adjacent regions (left and right), and we'll miss one
of them with range_tree_in_range().
Also (as I had already mentioned before), I think that new ranges must
not be merged with the existing "vrange->purged == 1" ranges.
Otherwise, for some use cases, the whole idea of 'volatility' gets
broken. For example, when an application is processing a big buffer in
small consequent chunks (marking a chunk as volatile when done with
it), and the range gets 'purged' by the kernel early in this process
(when it's still small).
-- Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists