Skip to content

Commit

Permalink
swap_info: change to array of pointers
Browse files Browse the repository at this point in the history
The swap_info_struct is only 76 or 104 bytes, but it does seem wrong
to reserve an array of about 30 of them in bss, when most people will
want only one.  Change swap_info[] to an array of pointers.

That does need a "type" field in the structure: pack it as a char with
next type and short prio (aha, char is unsigned by default on PowerPC).
Use the (admittedly peculiar) name "type" throughout for this index.

/proc/swaps does not take swap_lock: I wouldn't want it to, but do take
care with barriers when adding a new item to the array (never removed).

Signed-off-by: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Hugh Dickins authored and Linus Torvalds committed Dec 15, 2009
1 parent f29ad6a commit efa90a9
Show file tree
Hide file tree
Showing 2 changed files with 117 additions and 94 deletions.
7 changes: 4 additions & 3 deletions include/linux/swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ enum {
* The in-memory structure used to track swap areas.
*/
struct swap_info_struct {
unsigned long flags;
int prio; /* swap priority */
int next; /* next entry on swap list */
unsigned long flags; /* SWP_USED etc: see above */
signed short prio; /* swap priority of this type */
signed char type; /* strange name for an index */
signed char next; /* next type on the swap list */
struct file *swap_file;
struct block_device *bdev;
struct list_head extent_list;
Expand Down
Loading

0 comments on commit efa90a9

Please sign in to comment.