vm deadlock avoidance for NFS, NBD and iSCSI (take 7)
Subsystems (23)
cover vm deadlock avoidance for NFS, NBD and iSCSI (take 7)
--
Yet another instance of my networked swap patches.
The patch-set consists of four parts:
- patches 1-2; the basic 'framework' for deadlock avoidance
- patches 3-9; implement swap over NFS
- patches 10-13; implement swap over NBD
- patches 14-20; implement swap over iSCSI
The iSCSI work depends on their .19 tree and does need some more work, but does work in its current state.
As stated in previous posts, NFS and iSCSI survive service failures and reconnect properly during heavy swapping.
Linus, when I mentioned swap over network to you in Ottawa, you said it was a valid use case, that people actually do and want this. Can you agree with the approach taken in these patches?
Peter
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/20 mm: serialize access to min_free_kbytes
There is a small race between the procfs caller and the memory hotplug caller of setup_per_zone_pages_min(). Not a big deal, but the next patch will add yet another caller. Time to close the gap.
--- mm/page_alloc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
mm/page_alloc.c +13 -3
@@ -81,6 +81,7 @@ struct zone *zone_table[1 << ZONETABLE_SEXPORT_SYMBOL (zone_table);static char *zone_names[MAX_NR_ZONES ] = {"DMA" ,"DMA32" ,"Normal" ,"HighMem" }; +static DEFINE_SPINLOCK (min_free_lock);int min_free_kbytes =1024 ;unsigned long __meminitdata nr_kernel_pages;
@@ -2190,11 +2191,11 @@ static void setup_per_zone_lowmem_reserv }/* -* setup_per_zone_pages_min - called when min_free_kbytes changes. Ensures +* __setup_per_zone_pages_min - called when min_free_kbytes changes. Ensures * that the pages_{min,low,high} values for each zone are set correctly * with respect to min_free_kbytes. */ -void setup_per_zone_pages_min (void ) +static void __setup_per_zone_pages_min (void ) {unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT -10 );unsigned long lowmem_pages =0 ;
@@ -2248,6 +2249,15 @@ void setup_per_zone_pages_min(void)calculate_totalreserve_pages (); } +void setup_per_zone_pages_min (void ) +{ +unsigned long flags; + +spin_lock_irqsave (&min_free_lock, flags); +__setup_per_zone_pages_min (); +spin_unlock_irqrestore (&min_free_lock, flags); +} +/* * Initialise min_free_kbytes. *
@@ -2283,7 +2293,7 @@ static int __init init_per_zone_pages_mi min_free_kbytes =128 ;if (min_free_kbytes >65536 ) min_free_kbytes =65536 ; -setup_per_zone_pages_min (); +__setup_per_zone_pages_min ();setup_per_zone_lowmem_reserve ();return 0 ; }
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/20 net: vm deadlock avoidance core
In reply to Peter ZijlstraIn order to provide robust networked block devices there must be a guarantee of progress. That is, the block device must never stall because of (physical) OOM, because the device itself might be needed to get out of it (reclaim).
This means that the device queue must always be unplugable, this in turn means that it must always find enough memory to build/send packets over the network _and_ receive (level 7) ACKs for those packets.
The network stack has a huge capacity for buffering packets; waiting for user-space to read them. There is a practical limit imposed to avoid DoS scenarios. These two things make for a deadlock; what if the receive limit is reached and all packets are buffered in non-critical sockets (those not serving the network block device waiting for an ACK to free a page).
Memory pressure will add to that; what if there is simply no memory left to receive packets in.
This patch provides a service to register sockets as critical; SOCK_VMIO is a promise the socket will never block on receive. Along with with a memory reserve that will service a limited number of packets this can guarantee a limited service to these critical sockets.
When we make sure that packets allocated from the reserve will only service critical sockets we will not lose the memory and can guarantee progress.
Since memory is tight and the reserve modest, we do not want to lose memory to fragmentation effects. Hence a very simple allocator is used to guarantee that the memory used for each packet is returned to the page allocator.
(Note on the name SOCK_VMIO; the basic problem is a circular dependency between the network and virtual memory subsystems which needs to be broken. This does make VM network IO - and only VM network IO - special, it does not generalize)
Converted protocols:
IPv4 & IPv6:
- icmp
- udp
- tcp
IPv4:
- igmp
Caveat: currently there is no support for higher order allocations. So basically everything jumbo frame will fail for these situations. To mitigate this one could add a tiny pool of pre-allocated 2nd-order pages to the emergency allocator.
--- include/linux/gfp.h | 3 + include/linux/mmzone.h | 1 include/linux/skbuff.h | 13 +++++-- include/net/sock.h | 39 +++++++++++++++++++++ mm/page_alloc.c | 35 +++++++++++++++++-- net/core/skbuff.c | 85 +++++++++++++++++++++++++++++++++++++---------- net/core/sock.c | 88 +++++++++++++++++++++++++++++++++++++++++++++++++ net/ipv4/icmp.c | 3 + net/ipv4/igmp.c | 3 + net/ipv4/tcp_ipv4.c | 3 + net/ipv4/udp.c | 8 +++- net/ipv6/icmp.c | 3 + net/ipv6/tcp_ipv6.c | 3 + net/ipv6/udp.c | 3 + 14 files changed, 263 insertions(+), 27 deletions(-)
include/linux/gfp.h +2 -1
@@ -46,6 +46,7 @@ struct vm_area_struct;#define __GFP_ZERO ((__force gfp_t)0x8000u)/* Return zeroed page on success */ #define __GFP_NOMEMALLOC ((__force gfp_t)0x10000u)/* Don't use emergency reserves */ #define __GFP_HARDWALL ((__force gfp_t)0x20000u)/* Enforce hardwall cpuset memory allocs */ +#define __GFP_EMERGENCY ((__force gfp_t)0x40000u)/* Use emergency reserves */ #define __GFP_BITS_SHIFT 20/* Room for 20 __GFP_FOO bits */ #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
@@ -54,7 +55,7 @@ struct vm_area_struct;#define GFP_LEVEL_MASK (__GFP_WAIT|__GFP_HIGH|__GFP_IO|__GFP_FS| \ __GFP_COLD|__GFP_NOWARN|__GFP_REPEAT| \ __GFP_NOFAIL|__GFP_NORETRY|__GFP_NO_GROW|__GFP_COMP| \ - __GFP_NOMEMALLOC|__GFP_HARDWALL) + __GFP_NOMEMALLOC|__GFP_HARDWALL|__GFP_EMERGENCY)/* This equals 0, but use constants in case they ever change */ #define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
include/linux/mmzone.h +1 -0
@@ -421,6 +421,7 @@ int percpu_pagelist_fraction_sysctl_hand void __user *, size_t *, loff_t *);int sysctl_min_unmapped_ratio_sysctl_handler (struct ctl_table *,int ,struct file *,void __user *,size_t *,loff_t *); +void adjust_memalloc_reserve (int pages);#include <linux/topology.h> /* Returns the number of the current Node. */
include/linux/skbuff.h +9 -4
@@ -282,7 +282,8 @@ struct sk_buff { nfctinfo:3 ; __u8 pkt_type:3, fclone:2, - ipvs_property:1; + ipvs_property:1, + emergency:1;__be16 protocol;void (*destructor)(struct sk_buff *skb);
@@ -327,10 +328,13 @@ struct sk_buff {#include <asm/system.h> +#define SKB_ALLOC_FCLONE 0x01 +#define SKB_ALLOC_RX 0x02 +extern void kfree_skb (struct sk_buff *skb);extern void __kfree_skb (struct sk_buff *skb);extern struct sk_buff *__alloc_skb (unsigned int size, -gfp_t priority,int fclone); +gfp_t priority,int flags);static inline struct sk_buff *alloc_skb (unsigned int size,gfp_t priority) {
@@ -340,7 +344,7 @@ static inline struct sk_buff *alloc_skb(static inline struct sk_buff *alloc_skb_fclone (unsigned int size,gfp_t priority) { -return __alloc_skb (size, priority,1 ); +return __alloc_skb (size, priority,SKB_ALLOC_FCLONE ); } extern struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp,
@@ -1101,7 +1105,8 @@ static inline void __skb_queue_purge(strstatic inline struct sk_buff *__dev_alloc_skb (unsigned int length,gfp_t gfp_mask) { -struct sk_buff *skb =alloc_skb (length +NET_SKB_PAD , gfp_mask); +struct sk_buff *skb = +__alloc_skb (length +NET_SKB_PAD , gfp_mask,SKB_ALLOC_RX );if (likely (skb))skb_reserve (skb,NET_SKB_PAD );return skb;
include/net/sock.h +39 -0
@@ -391,6 +391,7 @@ enum sock_flags {SOCK_RCVTSTAMP ,/* %SO_TIMESTAMP setting */ SOCK_LOCALROUTE ,/* route locally only, %SO_DONTROUTE setting */ SOCK_QUEUE_SHRUNK ,/* write queue has been shrunk recently */ + SOCK_VMIO, /* the VM depends on us - make sure we're serviced */ };static inline void sock_copy_flags (struct sock *nsk,struct sock *osk)
@@ -413,6 +414,44 @@ static inline int sock_flag(struct sockreturn test_bit (flag, &sk->sk_flags); } +static inline int sk_has_vmio (struct sock *sk) +{ +return sock_flag (sk,SOCK_VMIO ); +} + +#define MAX_PAGES_PER_PACKET 2 +#define MAX_FRAGMENTS ((65536 + 1500 - 1) / 1500) +/* +* Set an upper limit on the number of pages used for RX skbs. +*/ +#define RX_RESERVE_PAGES (64 * MAX_PAGES_PER_PACKET) + +/* +* Guestimate the per request queue TX upper bound. +*/ +#define TX_RESERVE_PAGES \ + (4 * MAX_FRAGMENTS * MAX_PAGES_PER_PACKET) + +extern atomic_t vmio_socks; +extern atomic_t emergency_rx_pages_used; + +static inline int sk_vmio_socks (void ) +{ +return atomic_read (&vmio_socks); +} + +extern void *sk_emergency_rx_alloc (size_t size,gfp_t gfp_mask); + +static inline void sk_emergency_rx_free (void *page,size_t size) +{ +free_page ((unsigned long )page); +atomic_dec (&emergency_rx_pages_used); +} + +extern void sk_adjust_memalloc (int socks,int tx_reserve_pages); +extern int sk_set_vmio (struct sock *sk); +extern int sk_clear_vmio (struct sock *sk); +static inline void sk_acceptq_removed (struct sock *sk) { sk->sk_ack_backlog--;
mm/page_alloc.c +32 -3
@@ -83,6 +83,7 @@ EXPORT_SYMBOL(zone_table);static char *zone_names[MAX_NR_ZONES ] = {"DMA" ,"DMA32" ,"Normal" ,"HighMem" };static DEFINE_SPINLOCK (min_free_lock);int min_free_kbytes =1024 ; +int var_free_kbytes;unsigned long __meminitdata nr_kernel_pages;unsigned long __meminitdata nr_all_pages;
@@ -971,8 +972,8 @@ restart:/* This allocation should allow future memory freeing. */ -if (((p->flags &PF_MEMALLOC ) ||unlikely (test_thread_flag (TIF_MEMDIE ))) - && !in_interrupt ()) { +if ((((p->flags &PF_MEMALLOC ) ||unlikely (test_thread_flag (TIF_MEMDIE ))) + && !in_interrupt ()) || (gfp_mask & __GFP_EMERGENCY)) {if (!(gfp_mask & __GFP_NOMEMALLOC)) { nofail_alloc:/* go through the zonelist yet again, ignoring mins */
@@ -2197,7 +2198,8 @@ static void setup_per_zone_lowmem_reserv*/ static void __setup_per_zone_pages_min (void ) { -unsigned long pages_min = min_free_kbytes >> (PAGE_SHIFT -10 ); +unsigned pages_min = (min_free_kbytes + var_free_kbytes) + >> (PAGE_SHIFT -10 );unsigned long lowmem_pages =0 ;struct zone *zone;unsigned long flags;
@@ -2258,6 +2260,33 @@ void setup_per_zone_pages_min(void)spin_unlock_irqrestore (&min_free_lock, flags); } +/** +* adjust_memalloc_reserve - adjust the memalloc reserve +* @pages: number of pages to add +* +* It adds a number of pages to the memalloc reserve; if +* the number was positive it kicks kswapd into action to +* satisfy the higher watermarks. +* +* NOTE: there is only a single caller, hence no locking. +*/ +void adjust_memalloc_reserve (int pages) +{ + var_free_kbytes += pages << (PAGE_SHIFT -10 ); +BUG_ON (var_free_kbytes <0 ); +setup_per_zone_pages_min (); +if (pages >0 ) { +struct zone *zone; +for_each_zone (zone) +wakeup_kswapd (zone,0 ); + } +if (pages) +printk (KERN_DEBUG "Emergency reserve: %d\n" , + var_free_kbytes); +} + +EXPORT_SYMBOL_GPL (adjust_memalloc_reserve); +/* * Initialise min_free_kbytes. *
net/core/skbuff.c +67 -18
181 lines not on this page · raw message
net/ipv4/icmp.c +3 -0
@@ -938,6 +938,9 @@ int icmp_rcv(struct sk_buff *skb) goto error; } +if (unlikely (skb->emergency)) + goto drop; +if (!pskb_pull (skb,sizeof (struct icmphdr ))) goto error;
net/ipv4/tcp_ipv4.c +3 -0
@@ -1093,6 +1093,9 @@ int tcp_v4_rcv(struct sk_buff *skb)if (!sk) goto no_tcp_socket; +if (unlikely (skb->emergency && !sk_has_vmio (sk))) + goto discard_and_relse; + process:if (sk->sk_state ==TCP_TIME_WAIT ) goto do_time_wait;
net/ipv4/udp.c +7 -1
@@ -1136,7 +1136,12 @@ int udp_rcv(struct sk_buff *skb) sk =udp_v4_lookup (saddr, uh->source, daddr, uh->dest, skb->dev->ifindex);if (sk !=NULL ) { -int ret =udp_queue_rcv_skb (sk, skb); +int ret; + +if (unlikely (skb->emergency && !sk_has_vmio (sk))) + goto drop_noncritical; + + ret =udp_queue_rcv_skb (sk, skb);sock_put (sk);/* a return value > 0 means to resubmit the input, but
@@ -1147,6 +1152,7 @@ int udp_rcv(struct sk_buff *skb)return 0 ; } +drop_noncritical:if (!xfrm4_policy_check (NULL ,XFRM_POLICY_IN , skb)) goto drop;nf_reset (skb);
net/core/sock.c +88 -0
100 lines not on this page · raw message
net/ipv6/icmp.c +3 -0
@@ -599,6 +599,9 @@ static int icmpv6_rcv(struct sk_buff **pICMP6_INC_STATS_BH (idev,ICMP6_MIB_INMSGS ); +if (unlikely (skb->emergency)) + goto discard_it; + saddr = &skb->nh.ipv6h->saddr; daddr = &skb->nh.ipv6h->daddr;
net/ipv6/tcp_ipv6.c +3 -0
@@ -1216,6 +1216,9 @@ static int tcp_v6_rcv(struct sk_buff **pif (!sk) goto no_tcp_socket; +if (unlikely (skb->emergency && !sk_has_vmio (sk))) + goto discard_and_relse; + process:if (sk->sk_state ==TCP_TIME_WAIT ) goto do_time_wait;
net/ipv6/udp.c +3 -0
@@ -499,6 +499,9 @@ static int udpv6_rcv(struct sk_buff **ps sk =udp_v6_lookup (saddr, uh->source, daddr, uh->dest, dev->ifindex);if (sk ==NULL ) { +if (unlikely (skb->emergency && !sk_has_vmio (sk))) + goto discard; +if (!xfrm6_policy_check (NULL ,XFRM_POLICY_IN , skb)) goto discard;
net/ipv4/igmp.c +3 -0
@@ -927,6 +927,9 @@ int igmp_rcv(struct sk_buff *skb)return 0 ; } +if (unlikely (skb->emergency)) + goto drop; +if (!pskb_may_pull (skb,sizeof (struct igmphdr ))) goto drop;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/20 mm: add support for non block device backed swap files
In reply to Peter ZijlstraA new addres_space_operations method is added:
int swapfile(struct address_space *, int)
When during sys_swapon() this method is found and returns no error the swapper_space.a_ops will proxy to sis->swap_file->f_mapping->a_ops.
The swapfile method will be used to communicate to the address_space that the VM relies on it, and the address_space should take adequate measures (like reserving memory for mempools or the like).
--- fs/buffer.c | 2 - include/linux/fs.h | 1 include/linux/swap.h | 4 +++ init/Kconfig | 5 ++++ mm/page_io.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++ mm/swap_state.c | 6 +++++ mm/swapfile.c | 27 ++++++++++++++++++++++ 7 files changed, 103 insertions(+), 2 deletions(-)
include/linux/swap.h +4 -0
@@ -115,6 +115,7 @@ enum {SWP_USED = (1 <<0 ),/* is slot in swap_info[] used? */ SWP_WRITEOK = (1 <<1 ),/* ok to write to this swap? */ SWP_ACTIVE = (SWP_USED |SWP_WRITEOK ), +SWP_FILE = (1 <<2 ),/* file swap area */ /* add others here before... */ SWP_SCANNING = (1 << 8), /* refcount in scan_swap_map */ };
@@ -212,6 +213,9 @@ extern void swap_unplug_io_fn(struct bac/* linux/mm/page_io.c */ extern int swap_readpage (struct file *,struct page *);extern int swap_writepage (struct page *page,struct writeback_control *wbc); +extern void swap_sync_page (struct page *page); +extern int swap_set_page_dirty (struct page *page); +extern int swap_releasepage (struct page *page,gfp_t gfp_mask);extern int rw_swap_page_sync (int ,swp_entry_t ,struct page *);/* linux/mm/swap_state.c */
init/Kconfig +5 -0
@@ -100,6 +100,11 @@ config SWAP used to provide more virtual memory than the actual RAM present in your computer. If unsure say Y. +config SWAP_FILE + bool "Support for paging to/from non block device files" + depends on SWAP + default n + config SYSVIPC bool "System V IPC" ---help---
mm/page_io.c +60 -0
84 lines not on this page · raw message
mm/swap_state.c +6 -0
@@ -26,8 +26,14 @@*/ static const struct address_space_operations swap_aops = { .writepage = swap_writepage, +#ifdef CONFIG_SWAP_FILE + .sync_page = swap_sync_page, + .set_page_dirty = swap_set_page_dirty, + .releasepage = swap_releasepage, +#else .sync_page = block_sync_page, .set_page_dirty = __set_page_dirty_nobuffers, +#endif .migratepage = migrate_page, };
mm/swapfile.c +26 -1
@@ -411,7 +411,12 @@ void free_swap_and_cache(swp_entry_t entif (page) {int one_user; +#ifdef CONFIG_SWAP_FILE +if (PagePrivate (page)) +page_mapping (page)->a_ops->releasepage (page,0 ); +#else BUG_ON (PagePrivate (page)); +#endif one_user = (page_count (page) ==2 );/* Only cache user (+us), or swap space full? Free it! */ /* Also recheck PageSwapCache after page is locked (above) */
@@ -944,6 +949,13 @@ static void destroy_swap_extents(structlist_del (&se->list);kfree (se); } +#ifdef CONFIG_SWAP_FILE +if (sis->flags &SWP_FILE ) { + sis->flags &= ~SWP_FILE ; + sis->swap_file->f_mapping->a_ops-> +swapfile (sis->swap_file->f_mapping,0 ); + } +#endif }/*
@@ -1036,6 +1048,19 @@ static int setup_swap_extents(struct swa goto done; } +#ifdef CONFIG_SWAP_FILE +if (sis->swap_file->f_mapping->a_ops->swapfile) { + ret = sis->swap_file->f_mapping->a_ops-> +swapfile (sis->swap_file->f_mapping,1 ); +if (!ret) { + sis->flags |=SWP_FILE ; + ret =add_swap_extent (sis,0 , sis->max,0 ); + *span = sis->pages; + } + goto done; + } +#endif + blkbits = inode->i_blkbits; blocks_per_page =PAGE_SIZE >> blkbits;
@@ -1592,7 +1617,7 @@ asmlinkage long sys_swapon(const char __mutex_lock (&swapon_mutex);spin_lock (&swap_lock); - p->flags =SWP_ACTIVE ; + p->flags |=SWP_WRITEOK ; nr_swap_pages += nr_good_pages; total_swap_pages += nr_good_pages;
include/linux/fs.h +1 -0
@@ -382,6 +382,7 @@ struct address_space_operations {/* migrate the contents of a page to the specified target */ int (*migratepage) (struct address_space *,struct page *,struct page *); +int (*swapfile)(struct address_space *,int ); };struct backing_dev_info ;
fs/buffer.c +1 -1
@@ -1567,7 +1567,7 @@ static void discard_buffer(struct buffer*/ int try_to_release_page (struct page *page,gfp_t gfp_mask) { -struct address_space *const mapping = page->mapping; +struct address_space *const mapping =page_mapping (page);BUG_ON (!PageLocked (page));if (PageWriteback (page))
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/20 mm: methods for teaching filesystems about PG_swapcache pages
In reply to Peter ZijlstraIn order to teach filesystems to handle swap cache pages, two new page functions are introduced:
pgoff_t page_file_index(struct page *); struct address_space *page_file_mapping(struct page *);
page_file_index - gives the offset of this page in the file in PAGE_CACHE_SIZE blocks. Like page->index is for mapped pages, this function also gives the correct index for PG_swapcache pages.
page_file_mapping - gives the mapping backing the actual page; that is for swap cache pages it will give swap_file->f_mapping.
page_offset() is modified to use page_file_index(), so that it will give the expected result, even for PG_swapcache pages.
--- include/linux/mm.h | 30 ++++++++++++++++++++++++++++++ include/linux/pagemap.h | 2 +- include/linux/swap.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/swapops.h | 44 -------------------------------------------- 4 files changed, 79 insertions(+), 45 deletions(-)
include/linux/mm.h +30 -0
@@ -15,6 +15,7 @@#include <linux/fs.h> #include <linux/mutex.h> #include <linux/debug_locks.h> +#include <linux/swap.h> struct mempolicy ;struct anon_vma ;
@@ -579,6 +580,22 @@ static inline struct address_space *pagereturn mapping; } +static inline +struct swap_info_struct *page_swap_info (struct page *page) +{ +swp_entry_t swap = { .val =page_private (page) }; +BUG_ON (!PageSwapCache (page)); +return get_swap_info_struct (swp_type (swap)); +} + +static inline +struct address_space *page_file_mapping (struct page *page) +{ +if (unlikely (PageSwapCache (page))) +return page_swap_info (page)->swap_file->f_mapping; +return page->mapping; +} +static inline int PageAnon (struct page *page) {return ((unsigned long )page->mapping &PAGE_MAPPING_ANON ) !=0 ;
@@ -596,6 +613,19 @@ static inline pgoff_t page_index(struct }/* +* Return the file index of the page. Regular pagecache pages use ->index +* whereas swapcache pages use swp_offset(->private) +*/ +static inline pgoff_t page_file_index (struct page *page) +{ +if (unlikely (PageSwapCache (page))) { +swp_entry_t swap = { .val =page_private (page) }; +return swp_offset (swap); + } +return page->index; +} + +/* * The atomic page->_mapcount, like _count, starts from -1: * so that transitions both from it and to it can be tracked, * using atomic_inc_and_test and atomic_add_negative(-1).
include/linux/pagemap.h +1 -1
@@ -118,7 +118,7 @@ extern void __remove_from_page_cache(str*/ static inline loff_t page_offset (struct page *page) { -return ((loff_t )page->index) <<PAGE_CACHE_SHIFT ; +return ((loff_t )page_file_index (page)) <<PAGE_CACHE_SHIFT ; } static inline pgoff_t linear_page_index(struct vm_area_struct *vma,
include/linux/swap.h +48 -0
60 lines not on this page · raw message
include/linux/swapops.h +0 -44
48 lines not on this page · raw message
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/20 uml: rename arch/um remove_mapping()
In reply to Peter ZijlstraNow that 'include/linux/mm.h' includes 'include/linux/swap.h', the global remove_mapping() definition clashes with the arch/um one.
Rename the arch/um one.
--- arch/um/kernel/physmem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/um/kernel/physmem.c +3 -3
@@ -160,7 +160,7 @@ int physmem_subst_mapping(void *virt, instatic int physmem_fd =-1 ; -static void remove_mapping (struct phys_desc *desc) +static void um_remove_mapping (struct phys_desc *desc) {void *virt = desc->virt;int err;
@@ -184,7 +184,7 @@ int physmem_remove_mapping(void *virt)if (desc ==NULL )return (0 ); -remove_mapping (desc); +um_remove_mapping (desc);return (1 ); }
@@ -205,7 +205,7 @@ void physmem_forget_descriptor(int fd) page = list_entry(ele, struct phys_desc, list); offset = page->offset; addr = page->virt; -remove_mapping (page); +um_remove_mapping (page); err =os_seek_file (fd, offset);if (err) panic("physmem_forget_descriptor - failed to seek "
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 6/20 nfs: teach the NFS client how to treat PG_swapcache pages
In reply to Peter ZijlstraReplace all relevant occurences of page->index and page->mapping in the NFS client with the new page_file_index() and page_file_mapping() functions.
--- fs/nfs/file.c | 6 +++--- fs/nfs/pagelist.c | 8 ++++---- fs/nfs/read.c | 10 +++++----- fs/nfs/write.c | 28 ++++++++++++++-------------- 4 files changed, 26 insertions(+), 26 deletions(-)
fs/nfs/file.c +3 -3
@@ -303,17 +303,17 @@ static int nfs_commit_write(struct filestatic void nfs_invalidate_page (struct page *page,unsigned long offset) { -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;/* Cancel any unstarted writes on this page */ if (offset ==0 ) -nfs_sync_inode_wait (inode, page->index,1 ,FLUSH_INVALIDATE ); +nfs_sync_inode_wait (inode,page_file_index (page),1 ,FLUSH_INVALIDATE ); }static int nfs_release_page (struct page *page,gfp_t gfp) {if (gfp & __GFP_FS) -return !nfs_wb_page (page->mapping->host, page); +return !nfs_wb_page (page_file_mapping (page)->host, page);else /* * Avoid deadlock on nfs_wait_on_request().
fs/nfs/pagelist.c +4 -4
@@ -82,11 +82,11 @@ nfs_create_request(struct nfs_open_conte* update_nfs_request below if the region is not locked. */ req->wb_page = page;atomic_set (&req->wb_complete,0 ); - req->wb_index = page->index; + req->wb_index =page_file_index (page);page_cache_get (page);BUG_ON (PagePrivate (page));BUG_ON (!PageLocked (page)); -BUG_ON (page->mapping->host != inode); +BUG_ON (page_file_mapping (page)->host != inode); req->wb_offset = offset; req->wb_pgbase = offset; req->wb_bytes = count;
@@ -271,7 +271,7 @@ nfs_coalesce_requests(struct list_head ** nfs_scan_lock_dirty - Scan the radix tree for dirty requests * @nfsi: NFS inode * @dst: Destination list -* @idx_start: lower bound of page->index to scan +* @idx_start: lower bound of page_file_index(page) to scan * @npages: idx_start + npages sets the upper bound to scan. * * Moves elements from one of the inode request lists.
@@ -328,7 +328,7 @@ out:* @nfsi: NFS inode * @head: One of the NFS inode request lists * @dst: Destination list -* @idx_start: lower bound of page->index to scan +* @idx_start: lower bound of page_file_index(page) to scan * @npages: idx_start + npages sets the upper bound to scan. * * Moves elements from one of the inode request lists.
fs/nfs/read.c +5 -5
@@ -86,9 +86,9 @@ unsigned int nfs_page_length(struct inodif (i_size <=0 )return 0 ; idx = (i_size -1 ) >>PAGE_CACHE_SHIFT ; -if (page->index > idx) +if (page_file_index (page) > idx)return 0 ; -if (page->index != idx) +if (page_file_index (page) != idx)return PAGE_CACHE_SIZE ;return 1 + ((i_size -1 ) & (PAGE_CACHE_SIZE -1 )); }
@@ -595,11 +595,11 @@ int nfs_readpage_result(struct rpc_taskint nfs_readpage (struct file *file,struct page *page) {struct nfs_open_context *ctx; -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;int error;dprintk ("NFS: nfs_readpage (%p %ld@%lu)\n" , - page,PAGE_CACHE_SIZE , page->index); + page,PAGE_CACHE_SIZE ,page_file_index (page));nfs_inc_stats (inode,NFSIOS_VFSREADPAGE );nfs_add_stats (inode,NFSIOS_READPAGES ,1 );
@@ -647,7 +647,7 @@ static int readpage_async_filler(void *data, struct page *page) {struct nfs_readdesc *desc = (struct nfs_readdesc *)data; -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;struct nfs_page *new;unsigned int len;
fs/nfs/write.c +14 -14
@@ -145,13 +145,13 @@ void nfs_writedata_release(void *wdata)/* Adjust the file length if we're writing beyond the end */ static void nfs_grow_file (struct page *page,unsigned int offset,unsigned int count) { -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;loff_t end, i_size =i_size_read (inode);unsigned long end_index = (i_size -1 ) >>PAGE_CACHE_SHIFT ; -if (i_size >0 && page->index < end_index) +if (i_size >0 &&page_file_index (page) < end_index)return ; - end = ((loff_t )page->index <<PAGE_CACHE_SHIFT ) + ((loff_t )offset+count); + end =page_offset (page) + ((loff_t )offset+count);if (i_size >= end)return ;nfs_inc_stats (inode,NFSIOS_EXTENDWRITE );
@@ -174,11 +174,11 @@ static void nfs_mark_uptodate(struct pagreturn ; } - end_offs =i_size_read (page->mapping->host) -1 ; + end_offs =i_size_read (page_file_mapping (page)->host) -1 ;if (end_offs <0 )return ;/* Is this the last page? */ -if (page->index != (unsigned long )(end_offs >>PAGE_CACHE_SHIFT )) +if (page_file_index (page) != (unsigned long )(end_offs >>PAGE_CACHE_SHIFT ))return ;/* This is the last page: set PG_uptodate if we cover the entire * extent of the data, then zero the rest of the page.
@@ -293,7 +293,7 @@ static int wb_priority(struct writeback_int nfs_writepage (struct page *page,struct writeback_control *wbc) {struct nfs_open_context *ctx; -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;unsigned long end_index;unsigned offset =PAGE_CACHE_SIZE ;loff_t i_size =i_size_read (inode);
@@ -320,14 +320,14 @@ int nfs_writepage(struct page *page, strnfs_wb_page_priority (inode, page, priority);/* easy case */ -if (page->index < end_index) +if (page_file_index (page) < end_index) goto do_it;/* things got complicated... */ offset = i_size & (PAGE_CACHE_SIZE -1 );/* OK, are we completely out? */ err =0 ;/* potential race with truncate - ignore */ -if (page->index >= end_index+1 || !offset) +if (page_file_index (page) >= end_index+1 || !offset) goto out; do_it: ctx =nfs_find_open_context (inode,NULL ,FMODE_WRITE );
@@ -599,7 +599,7 @@ static void nfs_cancel_commit_list(struc* nfs_scan_dirty - Scan an inode for dirty requests * @inode: NFS inode to scan * @dst: destination list -* @idx_start: lower bound of page->index to scan. +* @idx_start: lower bound of page_file_index(page) to scan. * @npages: idx_start + npages sets the upper bound to scan. * * Moves requests from the inode's dirty page list.
@@ -625,7 +625,7 @@ nfs_scan_dirty(struct inode *inode, stru* nfs_scan_commit - Scan an inode for commit requests * @inode: NFS inode to scan * @dst: destination list -* @idx_start: lower bound of page->index to scan. +* @idx_start: lower bound of page_file_index(page) to scan. * @npages: idx_start + npages sets the upper bound to scan. * * Moves requests from the inode's 'commit' request list.
@@ -706,14 +706,14 @@ static struct nfs_page * nfs_update_requ end = offset + bytes; -if (nfs_wait_on_write_congestion (page->mapping, server->flags &NFS_MOUNT_INTR )) +if (nfs_wait_on_write_congestion (page_file_mapping (page), server->flags &NFS_MOUNT_INTR ))return ERR_PTR (-ERESTARTSYS );for (;;) {/* Loop over all inode entries and see if we find * A request for the page we wish to update */ spin_lock (&nfsi->req_lock); - req =_nfs_find_request (inode, page->index); + req =_nfs_find_request (inode,page_file_index (page));if (req) {if (!nfs_lock_request_dontget (req)) {int error;
@@ -784,7 +784,7 @@ static struct nfs_page * nfs_update_requint nfs_flush_incompatible (struct file *file,struct page *page) {struct nfs_open_context *ctx = (struct nfs_open_context *)file->private_data; -struct inode *inode = page->mapping->host; +struct inode *inode =page_file_mapping (page)->host;struct nfs_page *req;int status =0 ;/*
@@ -795,7 +795,7 @@ int nfs_flush_incompatible(struct file ** Also do the same if we find a request from an existing * dropped page. */ - req =nfs_find_request (inode, page->index); + req =nfs_find_request (inode,page_file_index (page));if (req) {if (req->wb_page != page || ctx != req->wb_context) status =nfs_wb_page (inode, page);
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 7/20 nfs: add a comment explaining the use of PG_private in the NFS client
In reply to Peter ZijlstraAdd a little comment explaining the use of PG_private in the NFS client.
--- fs/nfs/write.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/write.c +5 -0
@@ -417,6 +417,11 @@ static int nfs_inode_add_request(structif (nfs_have_delegation (inode,FMODE_WRITE )) nfsi->change_attr++; } +/* +* The PG_private bit is unfortunately needed if we want to fix the +* hole in the mmap semantics. If we do not set it, then the VM will +* fail to call the "releasepage" address ops. +*/ SetPagePrivate (req->wb_page); nfsi->npages++;atomic_inc (&req->wb_count);
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 8/20 nfs: enable swap on NFS
In reply to Peter ZijlstraNow that NFS can handle swap cache pages, add a swapfile method to allow swapping over NFS.
NOTE: this dummy method is obviously not enough to make it safe. A more complete version of the nfs_swapfile() function will be presented later in the series.
--- fs/nfs/file.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/nfs/file.c +6 -0
@@ -321,6 +321,11 @@ static int nfs_release_page(struct pagereturn 0 ; } +static int nfs_swapfile (struct address_space *mapping,int enable) +{ +return 0 ; +} +const struct address_space_operations nfs_file_aops = { .readpage = nfs_readpage, .readpages = nfs_readpages,
@@ -334,6 +339,7 @@ const struct address_space_operations nf#ifdef CONFIG_NFS_DIRECTIO .direct_IO = nfs_direct_IO, #endif + .swapfile = nfs_swapfile, };/*
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 9/20 nfs: make swap on NFS robust
In reply to Peter ZijlstraProvide a proper a_ops->swapfile() implementation for NFS. This will set the NFS socket to SOCK_VMIO and run socket reconnect under PF_MEMALLOC as well as reset SOCK_VMIO before engaging the protocol ->connect() method.
PF_MEMALLOC should allow the allocation of struct socket and related objects and the early (re)setting of SOCK_VMIO should allow us to receive the packets required for the TCP connection buildup.
(swapping continues over a server reset during a large (4k) ping flood)
--- fs/nfs/file.c | 2 - include/linux/sunrpc/xprt.h | 5 +++- net/sunrpc/sched.c | 4 +-- net/sunrpc/xprtsock.c | 47 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 54 insertions(+), 4 deletions(-)
fs/nfs/file.c +1 -1
@@ -323,7 +323,7 @@ static int nfs_release_page(struct pagestatic int nfs_swapfile (struct address_space *mapping,int enable) { -return 0 ; +return xs_swapper (NFS_CLIENT (mapping->host)->cl_xprt, enable); }const struct address_space_operations nfs_file_aops = {
net/sunrpc/xprtsock.c +47 -0
97 lines not on this page · raw message
include/linux/sunrpc/xprt.h +4 -1
@@ -147,7 +147,9 @@ struct rpc_xprt {unsigned int max_reqs;/* total slots */ unsigned long state;/* transport state */ unsigned char shutdown : 1, /* being shut down */ - resvport : 1; /* use a reserved port */ + resvport : 1, /* use a reserved port */ + swapper : 1; /* we're swapping over this +transport */ /* * XID
@@ -261,6 +263,7 @@ void xprt_disconnect(struct rpc_xprt **/ int xs_setup_udp (struct rpc_xprt *xprt,struct rpc_timeout *to);int xs_setup_tcp (struct rpc_xprt *xprt,struct rpc_timeout *to); +int xs_swapper (struct rpc_xprt *xprt,int enable);/* * Reserved bit positions in xprt->state
net/sunrpc/sched.c +2 -2
@@ -736,8 +736,8 @@ void * rpc_malloc(struct rpc_task *task,struct rpc_rqst *req = task->tk_rqstp;gfp_t gfp; -if (task->tk_flags &RPC_TASK_SWAPPER ) - gfp =GFP_ATOMIC ; +if (RPC_IS_SWAPPER (task)) + gfp =GFP_ATOMIC | __GFP_EMERGENCY;else gfp =GFP_NOFS ;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 10/20 mm: block device swap notification
In reply to Peter ZijlstraSome block devices need to do some extra work when used as swap device.
--- include/linux/fs.h | 1 + mm/swapfile.c | 7 +++++++ 2 files changed, 8 insertions(+)
include/linux/fs.h +1 -0
@@ -1017,6 +1017,7 @@ struct block_device_operations {int (*media_changed) (struct gendisk *);int (*revalidate_disk) (struct gendisk *);int (*getgeo)(struct block_device *,struct hd_geometry *); +int (*swapdev)(struct gendisk *,int enable);struct module *owner; };
mm/swapfile.c +7 -0
@@ -1273,6 +1273,8 @@ asmlinkage long sys_swapoff(const char _ inode = mapping->host;if (S_ISBLK (inode->i_mode)) {struct block_device *bdev =I_BDEV (inode); +if (bdev->bd_disk->fops->swapdev) + bdev->bd_disk->fops->swapdev (bdev->bd_disk,0 );set_blocksize (bdev, p->old_block_size);bd_release (bdev); }else {
@@ -1481,6 +1483,11 @@ asmlinkage long sys_swapdev(const char __if (error <0 ) goto bad_swap; p->bdev = bdev; +if (bdev->bd_disk->fops->swapdev) { + error = bdev->bd_disk->fops->swapdev (bdev->bd_disk,1 ); +if (error <0 ) + goto bad_swap; + } }else if (S_ISREG (inode->i_mode)) { p->bdev = inode->i_sb->s_bdev;mutex_lock (&inode->i_mutex);
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 11/20 nbd: request_fn fixup
In reply to Peter ZijlstraDropping the queue_lock opens up a nasty race, fix this race by plugging the device when we're done.
Also includes a small cleanup.
--- drivers/block/nbd.c | 67 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 18 deletions(-)
drivers/block/nbd.c +18 -13
@@ -97,20 +97,24 @@ static const char *nbdcmd_to_ascii(int c }#endif /* NDEBUG */ -static void nbd_end_request (struct request *req) +static void __nbd_end_request (struct request *req) {int uptodate = (req->errors ==0 ) ?1 :0 ; -request_queue_t *q = req->q; -unsigned long flags;dprintk (DBG_BLKDEV ,"%s: request %p: %s\n" , req->rq_disk->disk_name, req, uptodate?"done" :"failed" ); -spin_lock_irqsave (q->queue_lock, flags); -if (!end_that_request_first (req, uptodate, req->nr_sectors)) { +if (!end_that_request_first (req, uptodate, req->nr_sectors))end_that_request_last (req, uptodate); - } -spin_unlock_irqrestore (q->queue_lock, flags); +} + +static void nbd_end_request (struct request *req) +{ +request_queue_t *q = req->q; + +spin_lock_irq (q->queue_lock); +__nbd_end_request (req); +spin_unlock_irq (q->queue_lock); }/*
@@ -435,10 +439,8 @@ static void do_nbd_request(request_queuemutex_unlock (&lo->tx_lock);printk (KERN_ERR "%s: Attempted send on closed socket\n" , lo->disk->disk_name); - req->errors++; -nbd_end_request (req);spin_lock_irq (q->queue_lock); -continue ; + goto error_out; } lo->active_req = req;
@@ -463,10 +465,13 @@ static void do_nbd_request(request_queue error_out: req->errors++; -spin_unlock (q->queue_lock); -nbd_end_request (req); -spin_lock (q->queue_lock); +__nbd_end_request (req); } +/* +* q->queue_lock has been dropped, this opens up a race +* plug the device to close it. +*/ +blk_plug_device (q);return ; }
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 12/20 nbd: limit blk_queue
In reply to Peter ZijlstraLimit each request to 1 page, so that the request throttling also limits the number of in-flight pages.
--- drivers/block/nbd.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/block/nbd.c +3 -0
@@ -638,6 +638,9 @@ static int __init nbd_init(void)put_disk (disk); goto out; } +blk_queue_max_segment_size (disk->queue,PAGE_SIZE ); +blk_queue_max_hw_segments (disk->queue,1 ); +blk_queue_max_phys_segments (disk->queue,1 ); }if (register_blkdev (NBD_MAJOR ,"nbd" )) {
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 13/20 nbd: use swapdev hook to make swap deadlock free
In reply to Peter ZijlstraSet SOCK_VMIO on the NBD socket and make sure the request_fn always runs with PF_MEMALLOC when used as a swapper, this ensures we can always flush the requests.
--- drivers/block/nbd.c | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-)
drivers/block/nbd.c +31 -5
@@ -139,7 +139,6 @@ static int sock_xmit(struct socket *sockspin_unlock_irqrestore (¤t->sighand->siglock, flags); do { - sock->sk->sk_allocation = GFP_NOIO; iov.iov_base = buf; iov.iov_len = size; msg.msg_name = NULL;
@@ -406,10 +405,13 @@ static void nbd_clear_que(struct nbd_devstatic void do_nbd_request (request_queue_t * q) {struct request *req; +unsigned long pflags = current->flags; +struct nbd_device *lo = q->queuedata; + +if (lo->sock &&sk_has_vmio (lo->sock->sk)) + current->flags |=PF_MEMALLOC ;while ((req =elv_next_request (q)) !=NULL ) { -struct nbd_device *lo; -blkdev_dequeue_request (req);dprintk (DBG_BLKDEV ,"%s: request %p: dequeued (flags=%lx)\n" , req->rq_disk->disk_name, req, req->flags);
@@ -417,8 +419,6 @@ static void do_nbd_request(request_queueif (!(req->flags &REQ_CMD )) goto error_out; - lo = req->rq_disk->private_data; -BUG_ON (lo->magic !=LO_MAGIC );nbd_cmd (req) =NBD_CMD_READ ;
@@ -472,6 +472,7 @@ error_out:* plug the device to close it. */ blk_plug_device (q); + current->flags = pflags;return ; }
@@ -530,6 +531,7 @@ static int nbd_ioctl(struct inode *inodeif (S_ISSOCK (inode->i_mode)) { lo->file = file; lo->sock =SOCKET_I (inode); + lo->sock->sk->sk_allocation =GFP_NOIO ; error =0 ; }else {fput (file);
@@ -599,10 +601,33 @@ static int nbd_ioctl(struct inode *inodereturn -EINVAL ; } +static int nbd_swapdev (struct gendisk *disk,int enable) +{ +struct nbd_device *lo = disk->private_data; + +if (!lo->sock) +return -ENODEV ; + +if (enable) { +sk_adjust_memalloc (0 ,TX_RESERVE_PAGES ); +if (!sk_set_vmio (lo->sock->sk)) +printk (KERN_WARNING +"failed to set SOCK_VMIO on NBD socket\n" ); + }else { +if (!sk_clear_vmio (lo->sock->sk)) +printk (KERN_WARNING +"failed to clear SOCK_VMIO on NBD socket\n" ); +sk_adjust_memalloc (0 , -TX_RESERVE_PAGES ); + } + +return 0 ; +} +static struct block_device_operations nbd_fops = { .owner =THIS_MODULE , .ioctl = nbd_ioctl, + .swapdev = nbd_swapdev, };/*
@@ -638,6 +663,7 @@ static int __init nbd_init(void)put_disk (disk); goto out; } + disk->queue->queuedata = &nbd_dev[i];blk_queue_max_segment_size (disk->queue,PAGE_SIZE );blk_queue_max_hw_segments (disk->queue,1 );blk_queue_max_phys_segments (disk->queue,1 );
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 14/20 uml: enable scsi and add iscsi config
In reply to Peter ZijlstraEnable iSCSI on UML, dunno why SCSI was deemed broken, it works like a charm.
--- arch/um/Kconfig | 16 -------------- arch/um/Kconfig.scsi | 58 --------------------------------------------------- 2 files changed, 1 insertion(+), 73 deletions(-)
arch/um/Kconfig +1 -15
@@ -285,21 +285,7 @@ source "crypto/Kconfig" source "lib/Kconfig" -menu "SCSI support" -depends on BROKEN - -config SCSI - tristate "SCSI support" - -# This gives us free_dma, which scsi.c wants. -config GENERIC_ISA_DMA - bool - depends on SCSI - default y - -source "arch/um/Kconfig.scsi" - -endmenu +source "drivers/scsi/Kconfig" source "drivers/md/Kconfig"
arch/um/Kconfig.scsi deleted +0 -58
58 lines not on this page · raw message
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 15/20 iscsi: kernel side tcp connect
In reply to Peter ZijlstraMove tcp connection code from user- into kernel-space. This makes it possible to do TCP reconnect deadlock free.
(This patch requires userspace changes too)
--- drivers/scsi/iscsi_tcp.c | 108 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 83 insertions(+), 25 deletions(-)
drivers/scsi/iscsi_tcp.c +83 -25
@@ -35,6 +35,8 @@#include <linux/kfifo.h> #include <linux/scatterlist.h> #include <linux/mutex.h> +#include <linux/syscalls.h> +#include <linux/file.h> #include <net/tcp.h> #include <scsi/scsi_cmnd.h> #include <scsi/scsi_host.h>
@@ -1062,21 +1064,6 @@ iscsi_conn_set_callbacks(struct iscsi_cowrite_unlock_bh (&sk->sk_callback_lock); } -static void -iscsi_conn_restore_callbacks (struct iscsi_tcp_conn *tcp_conn) -{ -struct sock *sk = tcp_conn->sock->sk; - -/* restore socket callbacks, see also: iscsi_conn_set_callbacks() */ -write_lock_bh (&sk->sk_callback_lock); - sk->sk_user_data =NULL ; - sk->sk_data_ready = tcp_conn->old_data_ready; - sk->sk_state_change = tcp_conn->old_state_change; - sk->sk_write_space = tcp_conn->old_write_space; - sk->sk_no_check =0 ; -write_unlock_bh (&sk->sk_callback_lock); -} -/** * iscsi_send - generic send routine * @sk: kernel's socket
@@ -1741,6 +1728,77 @@ iscsi_tcp_ctask_xmit(struct iscsi_conn *return rc; } +static int +iscsi_tcp_ep_connect (struct sockaddr *dst_addr,int non_blocking, +uint64_t *ep_handle) +{ +struct socket *sock; +int rc, size, arg =1 , window =524288 ; + + rc =sock_create_kern (dst_addr->sa_family,SOCK_STREAM ,IPPROTO_TCP , + &sock); +if (rc <0 ) { +printk (KERN_ERR "Could not create socket %d.\n" , rc); +return rc; + } + sock->sk->sk_allocation =GFP_ATOMIC ; +/* +rc = sock->ops->setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, +(char __user *)&arg, sizeof(arg)); +if (rc) { +printk(KERN_ERR "Could not set TCP_NODELAY %d\n", rc); +goto release_sock; +} +*/ +/* should set like nfs */ +sock_setsockopt (sock,SOL_SOCKET ,SO_RCVBUF , + (char __user *)&window,sizeof (window)); +sock_setsockopt (sock,SOL_SOCKET ,SO_SNDBUF , + (char __user *)&window,sizeof (window)); + +if (dst_addr->sa_family ==PF_INET ) + size =sizeof (struct sockaddr_in ); +else if (dst_addr->sa_family ==PF_INET6 ) + size =sizeof (struct sockaddr_in6 ); +else { + rc = -EINVAL ; + goto release_sock; + } + +/* TODO we cannot block here */ + rc = sock->ops->connect (sock, (struct sockaddr *)dst_addr, size, +0 /*O_NONBLOCK*/ ); +if (rc == -EINPROGRESS ) + rc =0 ; +else if (rc) { +printk (KERN_ERR "Could not connect %d\n" , rc); + goto release_sock; + } + + rc =sock_map_fd (sock); +if (rc <0 ) + goto release_sock; + *ep_handle = (uint64_t )rc; +return 0 ; + +release_sock: +sock_release (sock); +return rc; +} + +static int +iscsi_tcp_ep_poll (uint64_t ep_handle,int timeout_ms) +{ +/* we cheated and blocked on the connect (TODO must fix) */ +return 1 ; +} + +static void +iscsi_tcp_ep_disconnect (uint64_t ep_handle) +{ +sys_close (ep_handle); +} +static struct iscsi_cls_conn *iscsi_tcp_conn_create (struct iscsi_cls_session *cls_session,uint32_t conn_idx) {
@@ -1795,11 +1853,7 @@ iscsi_tcp_release_conn(struct iscsi_connif (!tcp_conn->sock)return ; -sock_hold (tcp_conn->sock->sk); -iscsi_conn_restore_callbacks (tcp_conn); -sock_put (tcp_conn->sock->sk); - -sock_release (tcp_conn->sock); +fput (tcp_conn->sock->file); tcp_conn->sock =NULL ; conn->recv_lock =NULL ; }
@@ -1856,10 +1910,13 @@ iscsi_tcp_conn_bind(struct iscsi_cls_sesprintk (KERN_ERR "iscsi_tcp: sockfd_lookup failed %d\n" , err);return -EEXIST ; } +get_file (sock->file); err =iscsi_conn_bind (cls_session, cls_conn, is_leading); -if (err) +if (err) { +fput (sock->file);return err; + }/* bind iSCSI connection and socket */ tcp_conn->sock = sock;
@@ -2041,13 +2098,11 @@ iscsi_tcp_conn_get_param(struct iscsi_cl sk = tcp_conn->sock->sk;if (sk->sk_family ==PF_INET ) { inet =inet_sk (sk); - len =sprintf (buf,"%u.%u.%u.%u\n" , + len =sprintf (buf,NIPQUAD_FMT "\n" ,NIPQUAD (inet->daddr)); }else { np =inet6_sk (sk); - len =sprintf (buf, -"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n" , -NIP6 (np->daddr)); + len =sprintf (buf,NIP6_FMT "\n" ,NIP6 (np->daddr)); }mutex_unlock (&conn->xmitmutex);break ;
@@ -2185,6 +2240,9 @@ static struct iscsi_transport iscsi_tcp_ .get_session_param = iscsi_session_get_param, .start_conn = iscsi_conn_start, .stop_conn = iscsi_tcp_conn_stop, + .ep_connect = iscsi_tcp_ep_connect, + .ep_poll = iscsi_tcp_ep_poll, + .ep_disconnect = iscsi_tcp_ep_disconnect,/* IO */ .send_pdu = iscsi_conn_send_pdu, .get_stats = iscsi_conn_get_stats,
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 16/20 iscsi: add session context to ep_connect
In reply to Peter ZijlstraIn order to do a proper reconnect we need to know if we're a swapper. Only the session context can tell us that.
(This patch breaks the NETLINK_ISCSI ABI, userspace also needs a change)
--- drivers/infiniband/ulp/iser/iscsi_iser.c | 3 ++- drivers/scsi/iscsi_tcp.c | 3 ++- drivers/scsi/scsi_transport_iscsi.c | 4 +++- include/scsi/iscsi_if.h | 1 + include/scsi/scsi_transport_iscsi.h | 3 ++- 5 files changed, 10 insertions(+), 4 deletions(-)
drivers/scsi/iscsi_tcp.c +2 -1
@@ -1729,7 +1729,8 @@ iscsi_tcp_ctask_xmit(struct iscsi_conn * }static int -iscsi_tcp_ep_connect (struct sockaddr *dst_addr,int non_blocking, +iscsi_tcp_ep_connect (struct iscsi_cls_session *cls_session, +struct sockaddr *dst_addr,int non_blocking,uint64_t *ep_handle) {struct socket *sock;
drivers/scsi/scsi_transport_iscsi.c +3 -1
@@ -914,6 +914,7 @@ iscsi_if_transport_ep(struct iscsi_trans struct iscsi_uevent *ev, int msg_type) {struct sockaddr *dst_addr; +struct iscsi_cls_session *session;int rc =0 ;switch (msg_type) {
@@ -922,7 +923,8 @@ iscsi_if_transport_ep(struct iscsi_transreturn -EINVAL ; dst_addr = (struct sockaddr *)((char *)ev +sizeof (*ev)); - rc = transport->ep_connect (dst_addr, + session =iscsi_session_lookup (ev->u.ep_connect.sid); + rc = transport->ep_connect (session, dst_addr, ev->u.ep_connect.non_blocking, &ev->r.ep_connect_ret.handle);break ;
include/scsi/iscsi_if.h +1 -0
@@ -117,6 +117,7 @@ struct iscsi_uevent { } get_stats;struct msg_transport_connect {uint32_t non_blocking; +uint32_t sid; } ep_connect;struct msg_transport_poll {uint64_t ep_handle;
include/scsi/scsi_transport_iscsi.h +2 -1
@@ -120,7 +120,8 @@ struct iscsi_transport {int (*xmit_mgmt_task) (struct iscsi_conn *conn,struct iscsi_mgmt_task *mtask);void (*session_recovery_timedout) (struct iscsi_cls_session *session); -int (*ep_connect) (struct sockaddr *dst_addr,int non_blocking, +int (*ep_connect) (struct iscsi_cls_session *session, +struct sockaddr *dst_addr,int non_blocking,uint64_t *ep_handle);int (*ep_poll) (uint64_t ep_handle,int timeout_ms);void (*ep_disconnect) (uint64_t ep_handle);
drivers/infiniband/ulp/iser/iscsi_iser.c +2 -1
@@ -490,7 +490,8 @@ iscsi_iser_conn_get_stats(struct iscsi_c }static int -iscsi_iser_ep_connect (struct sockaddr *dst_addr,int non_blocking, +iscsi_iser_ep_connect (struct iscsi_cls_session *cls_session, +struct sockaddr *dst_addr,int non_blocking,__u64 *ep_handle) {int err;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 17/20 scsi: propagate the swapdev hook into the scsi stack
In reply to Peter ZijlstraAllow scsi devices to receive the swapdev notification.
--- drivers/scsi/sd.c | 13 +++++++++++++ include/scsi/scsi_host.h | 7 +++++++ 2 files changed, 20 insertions(+)
drivers/scsi/sd.c +13 -0
@@ -892,6 +892,18 @@ static long sd_compat_ioctl(struct file }#endif +static int sd_swapdev (struct gendisk *disk,int enable) +{ +int error =0 ; +struct scsi_disk *sdkp =scsi_disk (disk); +struct scsi_device *sdp = sdkp->device; + +if (sdp->host->hostt->swapdev) + error = sdp->host->hostt->swapdev (sdp, enable); + +return error; +} +static struct block_device_operations sd_fops = { .owner =THIS_MODULE , .open = sd_open,
@@ -903,6 +915,7 @@ static struct block_device_operations sd#endif .media_changed = sd_media_changed, .revalidate_disk = sd_revalidate_disk, + .swapdev = sd_swapdev, };/**
include/scsi/scsi_host.h +7 -0
@@ -288,6 +288,13 @@ struct scsi_host_template {int (*suspend)(struct scsi_device *,pm_message_t state);/* +* Notify that this device is used for swapping. +* +* Status: OPTIONAL +*/ +int (*swapdev)(struct scsi_device *,int enable); + +/* * Name of proc directory */ char *proc_name;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 18/20 netlink: add SOCK_VMIO support to AF_NETLINK
In reply to Peter ZijlstraModify the netlink code so that SOCK_VMIO has the desired effect on the user-space side of the connection.
Modify sys_{send,recv}msg to use sk->sk_allocation instead of GFP_KERNEL, this should not change existing behaviour because the default of sk->sk_allocation is GFP_KERNEL, and no user-space exposed socket would have it any different at this time.
This change allows the system calls to succeed for SOCK_VMIO sockets (who have sk->sk_allocation |= GFP_EMERGENCY) even under extreme memory pressure.
Since netlink_sendmsg is used to transfer msgs from user- to kernel-space treat the skb allocation there as a receive allocation.
Also export netlink_lookup, this is needed to locate the kernel side struct sock object associated with the user-space netlink socket.
--- include/linux/netlink.h | 1 + net/compat.c | 2 +- net/netlink/af_netlink.c | 8 +++++--- net/socket.c | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-)
net/netlink/af_netlink.c +5 -3
@@ -199,7 +199,7 @@ netlink_unlock_table(void)wake_up (&nl_table_wait); } -static __inline__struct sock *netlink_lookup (int protocol,u32 pid) +__inline__struct sock *netlink_lookup (int protocol,u32 pid) {struct nl_pid_hash *hash = &nl_table[protocol].hash;struct hlist_head *head;
@@ -1147,7 +1147,7 @@ static int netlink_sendmsg(struct kiocbif (len > sk->sk_sndbuf -32 ) goto out; err = -ENOBUFS ; - skb =alloc_skb (len,GFP_KERNEL ); + skb =__alloc_skb (len,GFP_KERNEL ,SKB_ALLOC_RX );if (skb==NULL ) goto out;
@@ -1178,7 +1178,8 @@ static int netlink_sendmsg(struct kiocbif (dst_group) {atomic_inc (&skb->users); -netlink_broadcast (sk, skb, dst_pid, dst_group,GFP_KERNEL ); +netlink_broadcast (sk, skb, dst_pid, dst_group, + sk->sk_allocation); } err =netlink_unicast (sk, skb, dst_pid, msg->msg_flags&MSG_DONTWAIT );
@@ -1788,6 +1789,7 @@ panic:core_initcall (netlink_proto_init); +EXPORT_SYMBOL (netlink_lookup);EXPORT_SYMBOL (netlink_ack);EXPORT_SYMBOL (netlink_run_queue);EXPORT_SYMBOL (netlink_queue_skip);
net/socket.c +3 -3
@@ -1790,7 +1790,7 @@ asmlinkage long sys_sendmsg(int fd, stru err = -ENOMEM ; iov_size = msg_sys.msg_iovlen *sizeof (struct iovec );if (msg_sys.msg_iovlen >UIO_FASTIOV ) { - iov =sock_kmalloc (sock->sk, iov_size,GFP_KERNEL ); + iov =sock_kmalloc (sock->sk, iov_size, sock->sk->sk_allocation);if (!iov) goto out_put; }
@@ -1818,7 +1818,7 @@ asmlinkage long sys_sendmsg(int fd, stru }else if (ctl_len) {if (ctl_len >sizeof (ctl)) { - ctl_buf =sock_kmalloc (sock->sk, ctl_len,GFP_KERNEL ); + ctl_buf =sock_kmalloc (sock->sk, ctl_len, sock->sk->sk_allocation);if (ctl_buf ==NULL ) goto out_freeiov; }
@@ -1891,7 +1891,7 @@ asmlinkage long sys_recvmsg(int fd, stru err = -ENOMEM ; iov_size = msg_sys.msg_iovlen *sizeof (struct iovec );if (msg_sys.msg_iovlen >UIO_FASTIOV ) { - iov =sock_kmalloc (sock->sk, iov_size,GFP_KERNEL ); + iov =sock_kmalloc (sock->sk, iov_size, sock->sk->sk_allocation);if (!iov) goto out_put; }
include/linux/netlink.h +1 -0
@@ -150,6 +150,7 @@ struct netlink_skb_parms#define NETLINK_CREDS (skb) (&NETLINK_CB((skb)).creds) +extern struct sock *netlink_lookup (int protocol,__u32 pid);extern struct sock *netlink_kernel_create (int unit,unsigned int groups,void (*input)(struct sock *sk,int len),struct module *module);extern void netlink_ack (struct sk_buff *in_skb,struct nlmsghdr *nlh,int err);extern int netlink_has_listeners (struct sock *sk,unsigned int group);
net/compat.c +1 -1
@@ -170,7 +170,7 @@ int cmsghdr_from_user_compat_to_kern(str* from the user. */ if (kcmlen > stackbuf_size) - kcmsg_base = kcmsg =sock_kmalloc (sk, kcmlen,GFP_KERNEL ); + kcmsg_base = kcmsg =sock_kmalloc (sk, kcmlen, sk->sk_allocation);if (kcmsg ==NULL )return -ENOBUFS ;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 19/20 mm: a process flags to avoid blocking allocations
In reply to Peter ZijlstraPF_MEM_NOWAIT - will make allocations fail before blocking. This is usefull to convert process behaviour to non-blocking.
--- include/linux/sched.h | 1 + mm/page_alloc.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-)
include/linux/sched.h +1 -0
@@ -1056,6 +1056,7 @@ static inline void put_task_struct(struc#define PF_SPREAD_SLAB 0x02000000/* Spread some slab caches over cpuset */ #define PF_MEMPOLICY 0x10000000/* Non-default NUMA mempolicy */ #define PF_MUTEX_TESTER 0x20000000/* Thread belongs to the rt mutex tester */ +#define PF_MEM_NOWAIT 0x40000000/* Make allocations fail instead of block */ /* * Only the _current_ task can read/write to tsk->flags, but other
mm/page_alloc.c +2 -2
@@ -912,11 +912,11 @@ struct page * fastcall __alloc_pages(gfp_t gfp_mask, unsigned int order, struct zonelist *zonelist) { - const gfp_t wait = gfp_mask & __GFP_WAIT; + struct task_struct *p = current; +const int wait = (gfp_mask & __GFP_WAIT) && !(p->flags &PF_MEM_NOWAIT );struct zone **z;struct page *page;struct reclaim_state reclaim_state; -struct task_struct *p = current;int do_retry;int alloc_flags;int did_some_progress;
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 20/20 iscsi: support for swapping over iSCSI.
In reply to Peter ZijlstraImplement sht->swapdev() for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets with SOCK_VMIO.
When used for swapping, TCP socket creation is done under GFP_MEMALLOC and the TCP connect is done with SOCK_VMIO to ensure their success. Also the netlink userspace interface is marked SOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs as mlockall() and needs no additional memory to operate).
Netlink requests are handled under the new PF_MEM_NOWAIT when a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.
The TCP receive path is handled under PF_MEMALLOC for SOCK_VMIO sockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.
--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)
drivers/scsi/iscsi_tcp.c +90 -13
@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h"
@@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags; + +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;/* * Save current SKB and its offset in the corresponding
@@ -866,7 +871,7 @@ more:if (unlikely (conn->suspend_rx)) {debug_tcp ("conn %d Rx suspended!\n" , conn->id); -return 0 ; + goto out; } if (tcp_conn->in_progress == IN_PROGRESS_WAIT_HEADER ||
@@ -877,7 +882,7 @@ more: goto nomore; else {iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); -return 0 ; + goto out; } }
@@ -891,7 +896,7 @@ more: tcp_conn->in_progress =IN_PROGRESS_DATA_RECV ; }else if (rc) {iscsi_conn_failure (conn, rc); -return 0 ; + goto out; } }
@@ -905,7 +910,7 @@ more:if (rc == -EAGAIN ) goto again;iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); -return 0 ; + goto out; }memcpy (&recv_digest, conn->data,sizeof (uint32_t ));
@@ -914,7 +919,7 @@ more:"0x%x != 0x%x\n" , recv_digest, tcp_conn->in.datadgst);iscsi_conn_failure (conn,ISCSI_ERR_DATA_DGST ); -return 0 ; + goto out; }else { debug_tcp("iscsi_tcp: data digest match!" "0x%x == 0x%x\n", recv_digest,
@@ -934,7 +939,7 @@ more:if (rc == -EAGAIN ) goto again;iscsi_conn_failure (conn,ISCSI_ERR_CONN_FAILED ); -return 0 ; + goto out; } tcp_conn->in.copy -= tcp_conn->in.padding; tcp_conn->in.offset += tcp_conn->in.padding;
@@ -969,6 +974,8 @@ more: nomore: processed = tcp_conn->in.offset - offset;BUG_ON (processed ==0 ); +out: + current->flags = pflags;return processed; again:
@@ -979,7 +986,7 @@ again:BUG_ON (processed > len); conn->rxdata_octets += processed; -return processed; + goto out; } static void
@@ -1735,14 +1742,26 @@ iscsi_tcp_ep_connect(struct iscsi_cls_se {struct socket *sock;int rc, size, arg =1 , window =524288 ; +int swapper =0 ; +unsigned long pflags = current->flags; + +if (cls_session) { +struct iscsi_session *session; + session =class_to_transport_session (cls_session); + swapper = session->swapper; + } + +if (swapper) + pflags |=PF_MEMALLOC ; rc =sock_create_kern (dst_addr->sa_family,SOCK_STREAM ,IPPROTO_TCP , &sock);if (rc <0 ) {printk (KERN_ERR "Could not create socket %d.\n" , rc); -return rc; + goto out; } - sock->sk->sk_allocation =GFP_ATOMIC ; + sock->sk->sk_allocation =GFP_NOIO ;// XXX GFP_ATOMIC; +/* rc = sock->ops->setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (char __user *)&arg, sizeof(arg));
@@ -1766,6 +1785,9 @@ iscsi_tcp_ep_connect(struct iscsi_cls_se goto release_sock; } +if (swapper) +sk_set_vmio (sock->sk); +/* TODO we cannot block here */ rc = sock->ops->connect (sock, (struct sockaddr *)dst_addr, size,0 /*O_NONBLOCK*/ );
@@ -1780,11 +1802,14 @@ iscsi_tcp_ep_connect(struct iscsi_cls_seif (rc <0 ) goto release_sock; *ep_handle = (uint64_t )rc; -return 0 ; + rc =0 ; +out: + current->flags = pflags; +return rc; release_sock:sock_release (sock); -return rc; + goto out; } static int
@@ -1926,10 +1951,11 @@ iscsi_tcp_conn_bind(struct iscsi_cls_ses sk = sock->sk; sk->sk_reuse =1 ; sk->sk_sndtimeo =15 *HZ ;/* FIXME: make it configurable */ - sk->sk_allocation =GFP_ATOMIC ;/* FIXME: disable Nagle's algorithm */ +BUG_ON (!sk_has_vmio (sk) && conn->session->swapper); +/* * Intercept TCP callbacks for sendfile like receive * processing.
@@ -2187,6 +2213,56 @@ static void iscsi_tcp_session_destroy(stiscsi_session_teardown (cls_session); } +#define NETLINK_RESERVE_PAGES (5 + 2 * (5 + 31)) +#define ISCSI_RESERVE_PAGES (NETLINK_RESERVE_PAGES + TX_RESERVE_PAGES) + +static int iscsi_swapdev (struct scsi_device *sdev,int enable) +{ +int error =0 ; +struct Scsi_Host *host; +struct iscsi_session *session; +struct iscsi_conn *conn; +struct sock *sk; +int daemon_pid; + + host = sdev->host; + session =iscsi_hostdata (host->hostdata); + session->swapper = !!enable; + daemon_pid =iscsi_if_daemon_pid (session->tt); + +if (enable) { +sk_adjust_memalloc (1 ,ISCSI_RESERVE_PAGES ); + sk =netlink_lookup (NETLINK_ISCSI ,0 ); +if (sk) +sk_set_vmio (sk); + sk =netlink_lookup (NETLINK_ISCSI , daemon_pid); +if (sk) +sk_set_vmio (sk); + } + +spin_lock (&session->lock); +list_for_each_entry (conn, &session->connections, item) { +struct iscsi_tcp_conn *tcp_conn = conn->dd_data; +if (enable) +sk_set_vmio (tcp_conn->sock->sk); +else +sk_clear_vmio (tcp_conn->sock->sk); + } +spin_unlock (&session->lock); + +if (!enable) { + sk =netlink_lookup (NETLINK_ISCSI , daemon_pid); +if (sk) +sk_clear_vmio (sk); + sk =netlink_lookup (NETLINK_ISCSI ,0 ); +if (sk) +sk_clear_vmio (sk); +sk_adjust_memalloc (-1 , -ISCSI_RESERVE_PAGES ); + } + +return error; +} +static struct scsi_host_template iscsi_sht = { .name ="iSCSI Initiator over TCP/IP" , .queuecommand = iscsi_queuecommand,
@@ -2199,6 +2275,7 @@ static struct scsi_host_template iscsi_s .use_clustering = DISABLE_CLUSTERING, .proc_name = "iscsi_tcp", .this_id = -1, + .swapdev = iscsi_swapdev, };static struct iscsi_transport iscsi_tcp_transport = {
include/scsi/libiscsi.h +1 -0
@@ -245,6 +245,7 @@ struct iscsi_session {int mgmtpool_max;/* size of mgmt array */ struct iscsi_mgmt_task **mgmt_cmds;/* Original mgmt arr */ struct iscsi_queue mgmtpool;/* Mgmt PDU's pool */ +int swapper;/* we are used to swap on */ };/*
drivers/scsi/scsi_transport_iscsi.c +21 -2
@@ -496,6 +496,13 @@ iscsi_if_transport_lookup(struct iscsi_treturn NULL ; } +int iscsi_if_daemon_pid (struct iscsi_transport *tt) +{ +return iscsi_if_transport_lookup (tt)->daemon_pid; +} + +EXPORT_SYMBOL_GPL (iscsi_if_daemon_pid); +static int iscsi_broadcast_skb (struct sk_buff *skb,gfp_t gfp) {
@@ -608,7 +615,7 @@ iscsi_if_send_reply(int pid, int seq, inint flags = multi ?NLM_F_MULTI :0 ;int t = done ?NLMSG_DONE : type; - skb =alloc_skb (len,GFP_KERNEL ); + skb =alloc_skb (len, nls->sk_allocation);/* * FIXME: * user is supposed to react on iferror == -ENOMEM;
@@ -970,6 +977,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, sstruct iscsi_cls_session *session;struct iscsi_cls_conn *conn;unsigned long flags; +int pid; priv =iscsi_if_transport_lookup (iscsi_ptr (ev->transport_handle));if (!priv)
@@ -979,7 +987,15 @@ iscsi_if_recv_msg(struct sk_buff *skb, sif (!try_module_get (transport->owner))return -EINVAL ; - priv->daemon_pid =NETLINK_CREDS (skb)->pid; + pid =NETLINK_CREDS (skb)->pid; +if (priv->daemon_pid >0 && priv->daemon_pid != pid) { +if (sk_has_vmio (nls)) { +struct sock * sk =netlink_lookup (NETLINK_ISCSI , pid); +BUG_ON (!sk); +WARN_ON (!sk_set_vmio (sk)); + } + } + priv->daemon_pid = pid;switch (nlh->nlmsg_type) {case ISCSI_UEVENT_CREATE_SESSION :
@@ -1094,7 +1110,10 @@ iscsi_if_rx(struct sock *sk, int len)if (rlen > skb->len) rlen = skb->len; +if (sk_has_vmio (sk)) + current->flags |=PF_MEM_NOWAIT ; err =iscsi_if_recv_msg (skb, nlh); + current->flags &= ~PF_MEM_NOWAIT ;if (err) { ev->type =ISCSI_KEVENT_IF_ERROR ; ev->iferror = err;
include/scsi/scsi_transport_iscsi.h +1 -1
@@ -218,8 +218,8 @@ extern int iscsi_destroy_session(structextern struct iscsi_cls_conn *iscsi_create_conn (struct iscsi_cls_session *sess,uint32_t cid);extern int iscsi_destroy_conn (struct iscsi_cls_conn *conn); +extern int iscsi_if_daemon_pid (struct iscsi_transport *tt);extern void iscsi_unblock_session (struct iscsi_cls_session *session);extern void iscsi_block_session (struct iscsi_cls_session *session); -#endif
--
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 4 lines · Peter Zijlstra
Linus, when I mentioned swap over network to you in Ottawa, you said it was a valid use case, that people actually do and want this. Can you agree with the approach taken in these patches?
Well, in all honesty, I don't think I really said "valid", but that I said that some crazy people want to do it, and that we should try to allow them their foibles.
So I'd be nervous to do any _guarantees_. I think that good VM policies should make it be something that works in general (the dirty mapping limits in particular), but I'd be a bit nervous about anybody taking it _too_ seriously. Crazy people are still crazy, they just might be right under certain reasonably-well-controlled circumstances.
Linus
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jens Axboe
maintainerRe: [PATCH 12/20] nbd: limit blk_queue
In reply to Peter ZijlstraQuoted 15 lines · Peter Zijlstra
Limit each request to 1 page, so that the request throttling also limits the number of in-flight pages.
Signed-off-by Peter Zijlstra <[email protected]>Signed-off-by Daniel Phillips <[email protected]>CC Pavel Machek <[email protected]>--- drivers/block/nbd.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-)Index:
linux-2.6/drivers/block/nbd.c
===================================================================
drivers/block/nbd.c static int __init nbd_init(void) · line 643
Quoted 6 lines
drivers/block/nbd.c +3
-0@@ -638,6 +638,9 @@ static int __init nbd_init(void)put_disk (disk); goto out; } +blk_queue_max_segment_size (disk->queue,PAGE_SIZE ); +blk_queue_max_hw_segments (disk->queue,1 ); +blk_queue_max_phys_segments (disk->queue,1 );
Another bandaid. What happens if nr_requests number of pages is still too many for a system? You just moved whatever problem you had, you didn't solve anything.
Signature · 7 lines
Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jens Axboe
maintainerRe: [PATCH 11/20] nbd: request_fn fixup
In reply to Peter ZijlstraQuoted 6 lines · Peter Zijlstra
drivers/block/nbd.c +0
-2@@ -463,10 +465,13 @@ static void do_nbd_request(request_queue error_out: req->errors++; -spin_unlock (q->queue_lock); -nbd_end_request (req);
drivers/block/nbd.c static void do_nbd_request(request_queue · line 476
Quoted 10 lines
drivers/block/nbd.c +6
-1-spin_lock (q->queue_lock); +__nbd_end_request (req); } +/* +* q->queue_lock has been dropped, this opens up a race +* plug the device to close it. +*/ +blk_plug_device (q);return ; }
This looks wrong, I wonder if this only fixes things for you because it happens to reinvoke the request handler after the timeout occurs? Your comment doesn't really describe what you think is going on, please describe in detail what you think is happening here that the plugging supposedly solves.
Generally the block device rule is that once you are invoked due to an unplug (or whatever) event, it is the responsibility of the block device to run the queue until it's done. So if you bail out of queue handling for whatever reason (might be resource starvation in hard- or software), you must make sure to reenter queue handling since the device will not get replugged while it has requests pending. Unless you run into some software resource shortage, running of the queue is done deterministically when you know resources are available (ie an io completes). The device plugging itself is only ever done when you encounter a shortage outside of your control (memory shortage, for instance) _and_ you don't already have pending work where you can invoke queueing from again.
Signature · 7 lines
Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 12 lines · Linus Torvalds
Quoted 4 lines · Peter Zijlstra
Linus, when I mentioned swap over network to you in Ottawa, you said it was a valid use case, that people actually do and want this. Can you agree with the approach taken in these patches?
Well, in all honesty, I don't think I really said "valid", but that I said that some crazy people want to do it, and that we should try to allow them their foibles.
Quoted 5 lines
So I'd be nervous to do any _guarantees_. I think that good VM policies should make it be something that works in general (the dirty mapping limits in particular), but I'd be a bit nervous about anybody taking it _too_ seriously. Crazy people are still crazy, they just might be right under certain reasonably-well-controlled circumstances.
(oops, forgot to cc: the list)
Personally, I'm a little unhappy with the added complexity here, I'm not convinced that this extra feature is worth it. In particular, adding to the address_space_operations, the block_device_operations, and creating a new swap index/offset interface just for this seems questionable. I feel like interface bloat should be reserved for features that have widespread use and benefit.
Not that I'm opposed to this feature, just that I think this patch is too invasive interface-wise.
NATE
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 11/20] nbd: request_fn fixup
In reply to Jens AxboeQuoted 4 lines · Jens Axboe
Generally the block device rule is that once you are invoked due to an unplug (or whatever) event, it is the responsibility of the block device to run the queue until it's done. So if you bail out of queue handling for whatever reason (might be resource starvation in hard- or software),
Quoted 8 lines
you must make sure to reenter queue handling since the device will not get replugged while it has requests pending. Unless you run into some software resource shortage, running of the queue is done deterministically when you know resources are available (ie an io completes). The device plugging itself is only ever done when you encounter a shortage outside of your control (memory shortage, for instance) _and_ you don't already have pending work where you can invoke queueing from again.
Or he could employ the blk_{start,stop}_queue() functions, if that model is easier for the driver (and brain).
Jeff
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Jens Axboe
maintainerRe: [PATCH 11/20] nbd: request_fn fixup
Quoted 14 lines · Jeff Garzik
Quoted 4 lines · Jens Axboe
Generally the block device rule is that once you are invoked due to an unplug (or whatever) event, it is the responsibility of the block device to run the queue until it's done. So if you bail out of queue handling for whatever reason (might be resource starvation in hard- or software),
Quoted 8 lines
you must make sure to reenter queue handling since the device will not get replugged while it has requests pending. Unless you run into some software resource shortage, running of the queue is done deterministically when you know resources are available (ie an io completes). The device plugging itself is only ever done when you encounter a shortage outside of your control (memory shortage, for instance) _and_ you don't already have pending work where you can invoke queueing from again.
Quoted 2 lines
Or he could employ the blk_{start,stop}_queue() functions, if that model is easier for the driver (and brain).
Definitely, yes.
Signature · 7 lines
Jens Axboe -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
In reply to Peter ZijlstraQuoted 41 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +1
-0@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 10 lines
drivers/scsi/iscsi_tcp.c +5
-1struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags; + +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;
Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I think we would want to set this flag at a lower level. Something closer to where the skbuf is allocated?
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
Quoted 49 lines · Mike Christie
Quoted 48 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +4
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags; +
Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 3 lines
drivers/scsi/iscsi_tcp.c +2
-0+if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
iscsi_tcp_data_recv()
iscsi_data_rescv()
iscsi_complete_pdu()
__iscsi_complete_pdu()
iscsi_recv_pdu()
alloc_skb( GFP_ATOMIC);Quoted 2 lines
I think we would want to set this flag at a lower level. Something closer to where the skbuf is allocated?
Is that the skbuff you were talking about? If so, I'd need to carve a path to pass the swapper information. I had that in a previous patch, but that was large and ugly. I had to go carrying gfp_t flags all through that call chain.
I could try again if you prefer that.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
Quoted 61 lines · Peter Zijlstra
Quoted 48 lines · Mike Christie
Quoted 47 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +3
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags;Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 4 lines
drivers/scsi/iscsi_tcp.c +3
-0+ +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
Quoted 7 lines
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);
You are right that is for the netlink interface. Could we move the PF_MEMALLOC setting and clearing to iscsi_recv_pdu and and add it to iscsi_conn_error in scsi_transport_iscsi.c so that iscsi_iser and qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.
Quoted 8 lines
Quoted 2 lines
I think we would want to set this flag at a lower level. Something closer to where the skbuf is allocated?
Is that the skbuff you were talking about? If so, I'd need to carve a path to pass the swapper information. I had that in a previous patch, but that was large and ugly. I had to go carrying
gfp_tflags all through that call chain.
In my original post I was just concerned about the sk_buff that gets passed to the iscsi layer in iscsi_tcp_data_recv. I was wondering if the chunk of code in the network layer or network driver that allocated that skbuff needed to set PF_MEMALLOC.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
Quoted 70 lines · Mike Christie
Quoted 61 lines · Peter Zijlstra
Quoted 48 lines · Mike Christie
Quoted 47 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +3
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags;Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 4 lines
drivers/scsi/iscsi_tcp.c +3
-0+ +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
Quoted 7 lines
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);
Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.
I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patch
but what conditional do you want to use for PF_MEMALLOC, an unconditional setting will be highly unpopular.
Hmm, perhaps you could key it of sk_has_vmio(nls)...
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
I think we would want to set this flag at a lower level. Something closer to where the skbuf is allocated?
Is that the skbuff you were talking about? If so, I'd need to carve a path to pass the swapper information. I had that in a previous patch, but that was large and ugly. I had to go carrying
gfp_tflags all through that call chain.
Quoted 4 lines
In my original post I was just concerned about the
sk_buffthat gets passed to the iscsi layer iniscsi_tcp_data_recv. I was wondering if the chunk of code in the network layer or network driver that allocated that skbuff needed to setPF_MEMALLOC.
(yeah I got that)
No, that got allocated because its a receive skb and !sk_vmio_socks(), and got passed up because sk_has_vmio(iscsi_tcp_conn->sock->sk).
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
Quoted 20 lines · Peter Zijlstra
Quoted 11 lines · Mike Christie
Quoted 10 lines
I thought I found allocations in that path, lemme search... found this:
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.
Quoted 7 lines
I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patchbut what conditional do you want to use for
PF_MEMALLOC, an unconditional setting will be highly unpopular.Hmm, perhaps you could key it of
sk_has_vmio(nls)...
On second thought, not such a good idea, that will still be too course. You only want to force feed stuff originating from sk_has_vmio(iscsi_tcp_conn->sock->sk) connections, not all connectections as soon as there is a swapper in the system.
In order to preserve that information you need extra state, abusing this process flags is as good as propagating __GFP_EMERGENCY down the call chain with extra gfp_t arguments, perhaps even better, since it will make sure we catch all allocations.
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
In reply to Peter ZijlstraQuoted 76 lines · Peter Zijlstra
Quoted 68 lines · Mike Christie
Quoted 60 lines · Peter Zijlstra
Quoted 48 lines · Mike Christie
Quoted 47 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +3
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags;Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 4 lines
drivers/scsi/iscsi_tcp.c +3
-0+ +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
Quoted 7 lines
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.
Quoted 3 lines
I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patch
You are drowning me in patches :) I did not see that one. I was still commenting on this patch :)
The new patch looks ok.
Quoted 4 lines
but what conditional do you want to use for
PF_MEMALLOC, an unconditional setting will be highly unpopular.Hmm, perhaps you could key it of
sk_has_vmio(nls)...
Yes.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
Quoted 76 lines · Mike Christie
Quoted 75 lines · Peter Zijlstra
Quoted 74 lines · Mike Christie
Quoted 60 lines · Peter Zijlstra
Quoted 48 lines · Mike Christie
Quoted 47 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +3
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags;Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 4 lines
drivers/scsi/iscsi_tcp.c +3
-0+ +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
Quoted 7 lines
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.
Quoted 9 lines
Quoted 3 lines
I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patchYou are drowning me in patches :) I did not see that one. I was still commenting on this patch :)
The new patch looks ok.
Oh, I think you need a sock_put to go with netlink lookup (lookup does a hold).
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
In reply to Peter ZijlstraQuoted 25 lines · Peter Zijlstra
Quoted 24 lines · Peter Zijlstra
Quoted 10 lines · Mike Christie
Quoted 10 lines
I thought I found allocations in that path, lemme search... found this:
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patchbut what conditional do you want to use for
PF_MEMALLOC, an unconditional setting will be highly unpopular.
Quoted 7 lines
Quoted 1 line
Hmm, perhaps you could key it of
sk_has_vmio(nls)...On second thought, not such a good idea, that will still be too course. You only want to force feed stuff originating from
sk_has_vmio(iscsi_tcp_conn->sock->sk)connections, not all connectections as soon as there is a swapper in the system.
You can move the iscsi_session->swapper field to the iscsi_cls_session and have iscsi_swapdev take a iscsi_cls_session and set that flag. iscsi_recv_pdu and iscsi_conn_error and all the llds can then access this bit.
Quoted 5 lines
In order to preserve that information you need extra state, abusing this process flags is as good as propagating
__GFP_EMERGENCYdown the call chain with extragfp_targuments, perhaps even better, since it will make sure we catch all allocations.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
In reply to Mike ChristieQuoted 81 lines · Mike Christie
Quoted 80 lines · Mike Christie
Quoted 78 lines · Peter Zijlstra
Quoted 68 lines · Mike Christie
Quoted 60 lines · Peter Zijlstra
Quoted 48 lines · Mike Christie
Quoted 47 lines · Peter Zijlstra
Implement
sht->swapdev()for iSCSI. This method takes care of reserving the extra memory needed and marking all relevant sockets withSOCK_VMIO.When used for swapping, TCP socket creation is done under
GFP_MEMALLOCand the TCP connect is done withSOCK_VMIOto ensure their success. Also the netlink userspace interface is markedSOCK_VMIO, this will ensure that even under pressure we can still communicate with the daemon (which runs asmlockall()and needs no additional memory to operate).Netlink requests are handled under the new
PF_MEM_NOWAITwhen a swapper is present. This ensures that the netlink socket will not block. User-space will need to retry failed requests.The TCP receive path is handled under
PF_MEMALLOCforSOCK_VMIOsockets. This makes sure we do not block the critical socket, and that we do not fail to process incomming data.Signed-off-by Peter Zijlstra <[email protected]>CC Mike Christie <[email protected]>--- drivers/scsi/iscsi_tcp.c | 103 +++++++++++++++++++++++++++++++----- drivers/scsi/scsi_transport_iscsi.c | 23 +++++++- include/scsi/libiscsi.h | 1 include/scsi/scsi_transport_iscsi.h | 2 4 files changed, 113 insertions(+), 16 deletions(-)Index:
linux-2.6/drivers/scsi/iscsi_tcp.c
===================================================================drivers/scsi/iscsi_tcp.c +3
-1@@ -42,6 +42,7 @@#include <scsi/scsi_host.h> #include <scsi/scsi.h> #include <scsi/scsi_transport_iscsi.h> +#include <scsi/scsi_device.h> #include "iscsi_tcp.h" @@ -845,9 +846,13 @@ iscsi_tcp_data_recv(read_descriptor_t *rint rc;struct iscsi_conn *conn = rd_desc->arg.data;struct iscsi_tcp_conn *tcp_conn = conn->dd_data; -int processed; +int processed =0 ;char pad[ISCSI_PAD_LEN ];struct scatterlist sg; +unsigned long pflags = current->flags;Quoted 8 lines
drivers/scsi/iscsi_tcp.c iscsi_tcp_data_recv(read_descriptor_t *r · line 856
Quoted 4 lines
drivers/scsi/iscsi_tcp.c +3
-0+ +if (sk_has_vmio (tcp_conn->sock->sk)) + current->flags |=PF_MEMALLOC ;Is this too late or not needed or what is it for? This function gets run from the network layer's softirq and at this point we have a skbuff with data that we want to process. The iscsi layer also does not allocate memory for read or write IO in this path.
I thought I found allocations in that path, lemme search... found this:
Quoted 7 lines
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patch
Quoted 8 lines
Quoted 5 lines
You are drowning me in patches :) I did not see that one. I was still commenting on this patch :)
The new patch looks ok.
Oh, I think you need a
sock_putto go with netlink lookup (lookup does a hold).
D'0h again, I'd forgotten I'd used it there too.
hit refresh :-)
Re: [PATCH 20/20] iscsi: support for swapping over iSCSI.
In reply to Mike ChristieQuoted 32 lines · Mike Christie
Quoted 21 lines · Peter Zijlstra
Quoted 20 lines · Peter Zijlstra
Quoted 10 lines · Mike Christie
Quoted 10 lines
I thought I found allocations in that path, lemme search... found this:
iscsi_tcp_data_recv()
iscsi_data_rescv()iscsi_complete_pdu() __iscsi_complete_pdu() iscsi_recv_pdu() alloc_skb( GFP_ATOMIC);Quoted 6 lines
You are right that is for the netlink interface. Could we move the
PF_MEMALLOCsetting and clearing toiscsi_recv_pduand and add it toiscsi_conn_errorinscsi_transport_iscsi.cso thatiscsi_iserand qla4xxx will have it set when they need it. I will send a patch for this along with a way to have the netlink sock vmio set for all iscsi drivers that need it.I already have such a patch, look at:
http://programming.kicks-ass.net/kernel-patches/vm_deadlock/current/iscsi_vmio.patchQuoted 9 lines
Quoted 4 lines
but what conditional do you want to use for
PF_MEMALLOC, an unconditional setting will be highly unpopular.Hmm, perhaps you could key it of
sk_has_vmio(nls)...On second thought, not such a good idea, that will still be too course. You only want to force feed stuff originating from
sk_has_vmio(iscsi_tcp_conn->sock->sk)connections, not all connectections as soon as there is a swapper in the system.
Quoted 10 lines
You can move the
iscsi_session->swapperfield to theiscsi_cls_sessionand haveiscsi_swapdevtake aiscsi_cls_sessionand set that flag.iscsi_recv_pduandiscsi_conn_errorand all the llds can then access this bit.Quoted 5 lines
In order to preserve that information you need extra state, abusing this process flags is as good as propagating
__GFP_EMERGENCYdown the call chain with extragfp_targuments, perhaps even better, since it will make sure we catch all allocations.
Oh yeah, on the send side we also allocate some memory for the netlink interface if there is a connection error (iscsi_conn_failure -> iscsi_conn_error). And when that is called from the transmit side we can change the GFP_ATOMICs to GFP_NOIOs since we have process context.
So I am just saying we need to set that flag in a couple more places (if you set it in iscsi_conn_error if iscsi_cls_session->swapper is set then don't worry about it), and that I need to change iscsi_conn_failure and iscsi_conn_error to take a gfp_t as an argument (or do a in_interrupt or something) so we can use GFP_NOIO in the transmit code.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>