From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933625AbaEMKey (ORCPT ); Tue, 13 May 2014 06:34:54 -0400 Received: from cantor2.suse.de ([195.135.220.15]:51249 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761217AbaEMKev (ORCPT ); Tue, 13 May 2014 06:34:51 -0400 Date: Tue, 13 May 2014 11:34:47 +0100 From: Mel Gorman To: Dan Streetman Cc: Hugh Dickins , Andrew Morton , Michal Hocko , Christian Ehrhardt , Weijie Yang , Rik van Riel , Johannes Weiner , Bob Liu , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shaohua Li , Steven Rostedt , Peter Zijlstra Subject: Re: [PATCHv2 4/4] swap: change swap_list_head to plist, add swap_avail_head Message-ID: <20140513103446.GO23991@suse.de> References: <1399057350-16300-1-git-send-email-ddstreet@ieee.org> <1399912700-30100-1-git-send-email-ddstreet@ieee.org> <1399912700-30100-5-git-send-email-ddstreet@ieee.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <1399912700-30100-5-git-send-email-ddstreet@ieee.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 12, 2014 at 12:38:20PM -0400, Dan Streetman wrote: > Originally get_swap_page() started iterating through the singly-linked > list of swap_info_structs using swap_list.next or highest_priority_index, > which both were intended to point to the highest priority active swap > target that was not full. The first patch in this series changed the > singly-linked list to a doubly-linked list, and removed the logic to start > at the highest priority non-full entry; it starts scanning at the highest > priority entry each time, even if the entry is full. > > Replace the manually ordered swap_list_head with a plist, swap_active_head. > Add a new plist, swap_avail_head. The original swap_active_head plist > contains all active swap_info_structs, as before, while the new > swap_avail_head plist contains only swap_info_structs that are active and > available, i.e. not full. Add a new spinlock, swap_avail_lock, to protect > the swap_avail_head list. > > Mel Gorman suggested using plists since they internally handle ordering > the list entries based on priority, which is exactly what swap was doing > manually. All the ordering code is now removed, and swap_info_struct > entries and simply added to their corresponding plist and automatically > ordered correctly. > > Using a new plist for available swap_info_structs simplifies and > optimizes get_swap_page(), which no longer has to iterate over full > swap_info_structs. Using a new spinlock for swap_avail_head plist > allows each swap_info_struct to add or remove themselves from the > plist when they become full or not-full; previously they could not > do so because the swap_info_struct->lock is held when they change > from full<->not-full, and the swap_lock protecting the main > swap_active_head must be ordered before any swap_info_struct->lock. > > Signed-off-by: Dan Streetman > Cc: Mel Gorman > Cc: Shaohua Li > Cc: Steven Rostedt > Cc: Peter Zijlstra > Acked-by: Mel Gorman -- Mel Gorman SUSE Labs