Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp867051pxf; Wed, 7 Apr 2021 13:41:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGvpARgv0vlzdNBeINvBWQRuHvXVjeVZ7JrPv5ob/8aIbDKcvazDPPWzEp8nUWL1Hr1QAF X-Received: by 2002:a63:d841:: with SMTP id k1mr4974852pgj.440.1617828068257; Wed, 07 Apr 2021 13:41:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617828068; cv=none; d=google.com; s=arc-20160816; b=GJR+51Pgz7u9KdyQSI/d4HY+yDRQnQkM11L2VDh1vaHkTAwWj+/m6WCLJ2hOt26vxk QIAEYSgLcnvPbjon1w4V6olISlCE0tk0lwK2X1ZShl9pC8ArPeVlQlA678CtqG7/63ba Vj0KfNERv0AUoOxh/laK9PhLjwK8oU1LLQgPTxAJ6haKU0n9AOD4EUdb4jP9VgAJ5snK v6/qTwUIxIlcWQks5eDqjsfXaEr8VGf1EPxY+0rr2/nQikKlTqQyhTJKfK0GfNq4O3he 143Xr6Xb0HJyfVVwFdTVVDeF3SShpeXG5k/OZqGuTo3XuIgRx2+bRZeQPFoxSI7YljG/ yahw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TXLJV284jnANi9LMOnlggnq83BgKfiBMnl0i0DxmbPc=; b=NJ4PhSknHlBYoVr9cxsURQ9wcowe+A+HPX4nITnh32dgXg8BhNVhqpf/EMOPaz3uMy Y9AkpgyPH9yvy/6nrBt37sUWqmF5OyKUPQjWD39aibo2OHoPV/u9lHeotHibyw7oPgEy Owwb7AGjndwDWB3o/AjjWy1JF+bysi+qosFd58Vaz8e3yLP4Jk6opxlZDNsYC1fvtoRi 4u9A7i3hG5QGM3qX5K/XSP+COS26FCpbSnth5iO1NHTUKGkgtZ+EVue/quPZzRvuVBN6 KHFq7gPK3a66nLJyEOIpXMAuKVT9gewvZ6VoxnV9aKKHEMZqdbOsHRMAwk9iBUbbIRan ZMOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cnPbl93i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e17si24042861pff.42.2021.04.07.13.40.55; Wed, 07 Apr 2021 13:41:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=cnPbl93i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350147AbhDGJdc (ORCPT + 99 others); Wed, 7 Apr 2021 05:33:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:45636 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233469AbhDGJd3 (ORCPT ); Wed, 7 Apr 2021 05:33:29 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1617787999; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=TXLJV284jnANi9LMOnlggnq83BgKfiBMnl0i0DxmbPc=; b=cnPbl93icESGJk/GD4BbQ+qSoUDlJBevwmLuFJa8AeqdA1krL3QaqS5DZ3P9r5zEjVkK1i H2HvfldrszuSQDwk8GbL2ECDGZpOafCWL9N/vDJM7U+u62rfDTlWLHcWO0FBKI3/mpQ+gD IOvqjjRnMsUfZifXOaLVBYjNcCvEkP8= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A72B0AF9E; Wed, 7 Apr 2021 09:33:19 +0000 (UTC) Date: Wed, 7 Apr 2021 11:33:18 +0200 From: Michal Hocko To: Oscar Salvador Cc: Mike Kravetz , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Roman Gushchin , Shakeel Butt , David Hildenbrand , Muchun Song , David Rientjes , Miaohe Lin , Peter Zijlstra , Matthew Wilcox , HORIGUCHI NAOYA , "Aneesh Kumar K . V" , Waiman Long , Peter Xu , Mina Almasry , Hillf Danton , Joonsoo Kim , Barry Song , Will Deacon , Andrew Morton Subject: Re: [PATCH v4 7/8] hugetlb: make free_huge_page irq safe Message-ID: References: <20210405230043.182734-1-mike.kravetz@oracle.com> <20210405230043.182734-8-mike.kravetz@oracle.com> <20210407091237.GC10058@linux> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210407091237.GC10058@linux> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 07-04-21 11:12:37, Oscar Salvador wrote: > On Mon, Apr 05, 2021 at 04:00:42PM -0700, Mike Kravetz wrote: > > Commit c77c0a8ac4c5 ("mm/hugetlb: defer freeing of huge pages if in > > non-task context") was added to address the issue of free_huge_page > > being called from irq context. That commit hands off free_huge_page > > processing to a workqueue if !in_task. However, this doesn't cover > > all the cases as pointed out by 0day bot lockdep report [1]. > > > > : Possible interrupt unsafe locking scenario: > > : > > : CPU0 CPU1 > > : ---- ---- > > : lock(hugetlb_lock); > > : local_irq_disable(); > > : lock(slock-AF_INET); > > : lock(hugetlb_lock); > > : > > : lock(slock-AF_INET); > > > > Shakeel has later explained that this is very likely TCP TX zerocopy > > from hugetlb pages scenario when the networking code drops a last > > reference to hugetlb page while having IRQ disabled. Hugetlb freeing > > path doesn't disable IRQ while holding hugetlb_lock so a lock dependency > > chain can lead to a deadlock. > > > > This commit addresses the issue by doing the following: > > - Make hugetlb_lock irq safe. This is mostly a simple process of > > changing spin_*lock calls to spin_*lock_irq* calls. > > - Make subpool lock irq safe in a similar manner. > > - Revert the !in_task check and workqueue handoff. > > > > [1] https://lore.kernel.org/linux-mm/000000000000f1c03b05bc43aadc@google.com/ > > > > Signed-off-by: Mike Kravetz > > Acked-by: Michal Hocko > > Reviewed-by: Muchun Song > > So, irq_lock_irqsave/spin_unlock_irqrestore is to be used in places > that might have been called from an IRQ context? Yes. spin_unlock_irq will enable interrupts unconditionally which is certainly not what we want if the path is called with IRQ disabled by the caller. -- Michal Hocko SUSE Labs