From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934137AbbBCXsd (ORCPT ); Tue, 3 Feb 2015 18:48:33 -0500 Received: from smtp97.ord1c.emailsrvr.com ([108.166.43.97]:56204 "EHLO smtp97.ord1c.emailsrvr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932558AbbBCXs1 (ORCPT ); Tue, 3 Feb 2015 18:48:27 -0500 X-Sender-Id: pasi.sjoholm@jollamobile.com Message-ID: <54D15E47.8020007@jolla.com> Date: Wed, 04 Feb 2015 01:48:23 +0200 From: =?windows-1252?Q?Pasi_Sj=F6holm?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Michal Hocko CC: linux-mm@kvack.org, linux-kernel@vger.kernel.org, =?windows-1252?Q?Pasi_Sj=F6holm?= Subject: Re: [PATCH] mm/swapfile.c: use spin_lock_bh with swap_lock to avoid deadlocks References: <1422894328-23051-1-git-send-email-pasi.sjoholm@jolla.com> <20150203131437.GA8914@dhcp22.suse.cz> In-Reply-To: <20150203131437.GA8914@dhcp22.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03.02.2015 15:14, Michal Hocko wrote: >> It is possible to get kernel in deadlock-state if swap_lock is not locked >> with spin_lock_bh by calling si_swapinfo() simultaneously through >> timer_function and registered vm shinker callback-function. >> >> BUG: spinlock recursion on CPU#0, main/2447 >> lock: swap_lock+0x0/0x10, .magic: dead4ead, .owner: main/2447, .owner_cpu: 0 >> [] (unwind_backtrace+0x0/0x11c) from [] (do_raw_spin_lock+0x48/0x154) >> [] (do_raw_spin_lock+0x48/0x154) from [] (si_swapinfo+0x10/0x90) >> [] (si_swapinfo+0x10/0x90) from [] (timer_function+0x24/0x258) > Who is calling si_swapinfo from timer_function? AFAICS the vanilla > kernel doesn't do that. Or am I missing something? Nothing in vanilla kernel, but "memnotify" (https://lkml.org/lkml/2012/1/17/182) together with modified lowmemorykiller (drivers/staging/android/lowmemorykiller.c) which takes in account also the available swap (calling si_swapinfo as well) will cause the deadlock. Memnotify uses timer (with backoff) for checking the memory pressure which can be then used to let the processes itself adjust their memory pressure before getting killed by the modified lowmemorykiller. Br, Pasi