From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965152AbcHJS43 (ORCPT ); Wed, 10 Aug 2016 14:56:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45762 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753677AbcHJS4X (ORCPT ); Wed, 10 Aug 2016 14:56:23 -0400 Date: Wed, 10 Aug 2016 18:27:19 +0200 From: Oleg Nesterov To: Bart Van Assche Cc: Peter Zijlstra , "mingo@kernel.org" , Andrew Morton , Johannes Weiner , Neil Brown , Michael Shaver , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] sched: Avoid that __wait_on_bit_lock() hangs Message-ID: <20160810162719.GA6883@redhat.com> References: <20160804140938.GB24652@twins.programming.kicks-ass.net> <16207b90-2e6c-fe23-1b4b-3763e5cf0384@sandisk.com> <20160808102213.GA6879@twins.programming.kicks-ass.net> <4091e252-18d9-1795-de63-9fbc678aa6b1@acm.org> <20160808162038.GA25927@redhat.com> <78fafdc1-d4ae-a9a2-169c-1d456b6e6e41@sandisk.com> <20160809171459.GA13840@redhat.com> <3cec7657-caa9-92ca-9f0e-34f073a6ed8c@sandisk.com> <20160810104555.GA3333@redhat.com> <426a381f-b1d9-e1f1-773d-75ccdccfa832@sandisk.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <426a381f-b1d9-e1f1-773d-75ccdccfa832@sandisk.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 10 Aug 2016 16:27:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/10, Bart Van Assche wrote: > > On 08/10/2016 03:46 AM, Oleg Nesterov wrote: > > OK. Could you try another debugging patch below? > > > > Oleg. > > --- > > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index e5a3244..9d5f892 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -711,6 +711,15 @@ static inline int page_has_private(struct page *page) > > return !!(page->flags & PAGE_FLAGS_PRIVATE); > > } > > > > +void unlock_page(struct page *page); > > +static inline void __ClearPageLocked_x(struct page *page) > > +{ > > + if (PageLocked(compound_head(page))) > > + unlock_page(page); > > +} > > + > > +#define __ClearPageLocked(page) __ClearPageLocked_x(page) > > + > > #undef PF_ANY > > #undef PF_HEAD > > #undef PF_NO_TAIL > > Hi Oleg, > > Are you sure that all __ClearPageLocked() users pass the compound head > to that macro? Hmm. it obviously should... which kernel version do you use for testing? >>From include/linux/page-flags.h __PAGEFLAG(Locked, locked, PF_NO_TAIL) and #define PF_NO_TAIL(page, enforce) ({ \ VM_BUG_ON_PGFLAGS(enforce && PageTail(page), page); \ compound_head(page);}) and this matches compound_head() in lock/unlock_page(). > --- a/include/linux/page-flags.h > +++ b/include/linux/page-flags.h > @@ -711,6 +711,17 @@ static inline int page_has_private(struct page *page) > return !!(page->flags & PAGE_FLAGS_PRIVATE); > } > > +void unlock_page(struct page *page); > +static inline void __ClearPageLocked_x(struct page *page) > +{ > + if (PageLocked(compound_head(page))) > + unlock_page(page); > + else > + __ClearPageLocked(page); > +} No, no. If you use an old kernel (which doesn't call compound_head() in lock_page()), then just remove compound_head() from __ClearPageLocked_x() above: static inline void __ClearPageLocked_x(struct page *page) { if (PageLocked(page)) unlock_page(page); } even if this shouldn't make any difference afaics, note the VM_BUG_ON_PGFLAGS() above. Oleg.