Re: swp_pager_meta_build DoS printf

From: Sergey Kandaurov <pluknet_at_gmail.com>
Date: Mon, 13 Aug 2012 09:49:38 +0400
On 2 July 2012 20:31, Bjoern A. Zeeb <bzeeb-lists_at_lists.zabbadoz.net> wrote:
>
> On 2. Jul 2012, at 14:36 , John Baldwin wrote:
>
>> On Sunday, July 01, 2012 8:23:31 am Bjoern A. Zeeb wrote:
>>> Hey,
>>>
>>> hitting this printf in swp_pager_meta_build()
>>>
>>>                        if (uma_zone_exhausted(swap_zone)) {
>>>                                printf("swap zone exhausted, increase kern.maxswzone\n");
>>>                                vm_pageout_oom(VM_OOM_SWAPZ);
>>>                                pause("swzonex", 10);
>>>                        } else
>>>
>>> seems to be an effective way to put the machine into a state of no recovery
>>> unless the memory situation would be able to clear itself.  Not that it wouldn't
>>> otherwise be any better but in addition having a couple of tenthousands of these
>>> going to console as well is really not helpful to try to do anything either.  Can
>>> we make it a log() call or something?
>>>
>>> /bz
>>>
>>> PS: I am not sure as I have seen it on someone else's machines and it's
>>> probably been ZFS that caused it.  I unfortunately neither had a way to
>>> get back in or break to a kernel debugger, so information is sparse.
>>
>> This used to be a silent deadlock before I added the printf() and the call to
>> OOM. :-P  Do you just want to ratelimit the printf?  We have an API to ratelimit
>> printf's already.
>
> Ratelimit would be fine;  I was writing that on the wrong time of the wrong day to
> just get it out;  could you do that?

Hi, looks like the discussion was abandoned.
What about this patch? It enables to ratelimit the printf.
Also, are the new variables put in the right places from the style pov?

Index: /usr/src/sys/vm/swap_pager.c
===================================================================
--- /usr/src/sys/vm/swap_pager.c        (revision 239171)
+++ /usr/src/sys/vm/swap_pager.c        (working copy)
_at__at_ -1804,8 +1804,10 _at__at_ restart:
 static void
 swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk)
 {
+       static struct timeval lastfail;
        struct swblock *swap;
        struct swblock **pswap;
+       static int curfail;
        int idx;

        VM_OBJECT_LOCK_ASSERT(object, MA_OWNED);
_at__at_ -1847,7 +1849,9 _at__at_ retry:
                        mtx_unlock(&swhash_mtx);
                        VM_OBJECT_UNLOCK(object);
                        if (uma_zone_exhausted(swap_zone)) {
-                               printf("swap zone exhausted, increase
kern.maxswzone\n");
+                               if (ppsratecheck(&lastfail, &curfail, 1))
+                                       printf("swap zone exhausted, "
+                                           "increase kern.maxswzone\n");
                                vm_pageout_oom(VM_OOM_SWAPZ);
                                pause("swzonex", 10);
                        } else

-- 
wbr,
pluknet
Received on Mon Aug 13 2012 - 03:49:40 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC