[ovs-dev] [PATCH] dpif-netdev: Garbage collect the exact match cache periodically.
Jarno Rajahalme
jrajahalme at nicira.com
Wed Nov 19 19:22:44 UTC 2014
On Nov 14, 2014, at 4:10 PM, Alex Wang <alexw at nicira.com> wrote:
> On current master, the exact match cache entry can keep reference to
> 'struct dp_netdev_flow' even after the flow is removed from the flow
> table. This means the free of allocated memory of the flow is delayed
> until the exact match cache entry is cleared or replaced.
>
> If the allocated memory is ahead of chunks of freed memory on heap,
> the delay will prevent the reclaim of those freed chunks, causing
> falsely high memory utilization.
>
> To fix the issue, this commit makes the owning thread conduct periodic
> garbage collection on the exact match cache and clear all dead entries.
>
> Signed-off-by: Alex Wang <alexw at nicira.com>
> ---
> lib/dpif-netdev.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index 65df19b..48394b3 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -433,6 +433,7 @@ static void dp_netdev_del_pmds_on_numa(struct dp_netdev *dp, int numa_id);
> static void dp_netdev_set_pmds_on_numa(struct dp_netdev *dp, int numa_id);
> static void dp_netdev_reset_pmd_threads(struct dp_netdev *dp);
>
> +static inline bool emc_entry_alive(struct emc_entry *ce);
> static void emc_clear_entry(struct emc_entry *ce);
>
> static void
> @@ -462,6 +463,18 @@ emc_cache_uninit(struct emc_cache *flow_cache)
> }
> }
>
> +static void
> +emc_cache_sweep(struct emc_cache *flow_cache)
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(flow_cache->entries); i++) {
> + if (!emc_entry_alive(&flow_cache->entries[i])) {
> + emc_clear_entry(&flow_cache->entries[i]);
> + }
> + }
> +}
> +
> static struct dpif_netdev *
> dpif_netdev_cast(const struct dpif *dpif)
> {
> @@ -2332,6 +2345,7 @@ reload:
>
> lc = 0;
>
> + emc_cache_sweep(&pmd->flow_cache);
This may cause some jitter, maybe it would be better to sweep only a small portion of the cache at each invocation instead? E.g., check one entry at a time. That should be enough to clean out the cache.
> ovsrcu_quiesce();
>
> atomic_read_relaxed(&pmd->change_seq, &seq);
> --
> 1.7.9.5
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
More information about the dev
mailing list