Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752222AbbFBWT5 (ORCPT ); Tue, 2 Jun 2015 18:19:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46687 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750836AbbFBWTq (ORCPT ); Tue, 2 Jun 2015 18:19:46 -0400 Date: Tue, 2 Jun 2015 15:19:45 -0700 From: Andrew Morton To: Dan Streetman Cc: Konrad Rzeszutek Wilk , Boris Ostrovsky , David Vrabel , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCHv3] frontswap: allow multiple backends Message-Id: <20150602151945.9d6b227157852e55a4edb692@linux-foundation.org> In-Reply-To: <1433282926-15100-1-git-send-email-ddstreet@ieee.org> References: <1433168544-26301-1-git-send-email-ddstreet@ieee.org> <1433282926-15100-1-git-send-email-ddstreet@ieee.org> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2203 Lines: 55 On Tue, 2 Jun 2015 18:08:46 -0400 Dan Streetman wrote: > Change frontswap single pointer to a singly linked list of frontswap > implementations. Update Xen tmem implementation as register no longer > returns anything. > > Frontswap only keeps track of a single implementation; any implementation > that registers second (or later) will replace the previously registered > implementation, and gets a pointer to the previous implementation that > the new implementation is expected to pass all frontswap functions to > if it can't handle the function itself. However that method doesn't > really make much sense, as passing that work on to every implementation > adds unnecessary work to implementations; instead, frontswap should > simply keep a list of all registered implementations and try each > implementation for any function. Most importantly, neither of the > two currently existing frontswap implementations in the kernel actually > do anything with any previous frontswap implementation that they > replace when registering. > > This allows frontswap to successfully manage multiple implementations > by keeping a list of them all. > offtopic trivia: this --- a/mm/frontswap.c~frontswap-allow-multiple-backends-fix +++ a/mm/frontswap.c @@ -111,14 +111,11 @@ static inline void inc_frontswap_invalid */ void frontswap_register_ops(struct frontswap_ops *ops) { - DECLARE_BITMAP(a, MAX_SWAPFILES); - DECLARE_BITMAP(b, MAX_SWAPFILES); + DECLARE_BITMAP(a, MAX_SWAPFILES) = { }; + DECLARE_BITMAP(b, MAX_SWAPFILES) = { }; struct swap_info_struct *si; unsigned int i; - bitmap_zero(a, MAX_SWAPFILES); - bitmap_zero(b, MAX_SWAPFILES); - spin_lock(&swap_lock); plist_for_each_entry(si, &swap_active_head, list) { if (!WARN_ON(!si->frontswap_map)) saves 64 bytes of text with my gcc. It shouldn't be open-coded here, but a new macro in bitmap.h could be useful, assuming it's a win for other sizes of bitmaps. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/