From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2BA34C433F5 for ; Tue, 11 Oct 2022 08:25:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8A0E06B0072; Tue, 11 Oct 2022 04:25:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 850DB6B0073; Tue, 11 Oct 2022 04:25:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 73F9F6B0074; Tue, 11 Oct 2022 04:25:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 655356B0072 for ; Tue, 11 Oct 2022 04:25:37 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3E3BF1C6E3D for ; Tue, 11 Oct 2022 08:25:37 +0000 (UTC) X-FDA: 80007984714.08.DA301B2 Received: from outbound-smtp58.blacknight.com (outbound-smtp58.blacknight.com [46.22.136.242]) by imf19.hostedemail.com (Postfix) with ESMTP id A2E281A0024 for ; Tue, 11 Oct 2022 08:25:35 +0000 (UTC) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp58.blacknight.com (Postfix) with ESMTPS id DB7DBFA76C for ; Tue, 11 Oct 2022 09:25:33 +0100 (IST) Received: (qmail 28258 invoked from network); 11 Oct 2022 08:25:33 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.198.246]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 11 Oct 2022 08:25:33 -0000 Date: Tue, 11 Oct 2022 09:25:30 +0100 From: Mel Gorman To: Vlastimil Babka Cc: Yu Zhao , Andrew Morton , Nicolas Saenz Julienne , Marcelo Tosatti , Michal Hocko , Hugh Dickins , Marek Szyprowski , LKML , Linux-MM Subject: Re: [PATCH 1/1] mm/page_alloc: Leave IRQs enabled for per-cpu page allocations Message-ID: <20221011082530.p2fk44dhglxulsou@techsingularity.net> References: <20220824141802.23395-1-mgorman@techsingularity.net> <20221010142208.ctsasloh7hbudupc@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1665476736; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FTUe1By7O3miTeAH8d9B0je5jAG/DdoaDzAk82kjr/E=; b=pVFdYeSMeqd9Oxtc+S0rL5tj+vlrQQyeop7L/7u02YnfuaqjvTE/bf2+ZVfYJqKycyOVR/ KTxI4n2aHhIMoVCKcMVIIVH3/R7yOq/iNkN9QJ/Oh8b84rhLcddw8y7vhMtXdAWFkFCUEt VYmpRU1KIC7lJmIb6aD44l80i74Z8oI= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.136.242 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1665476736; a=rsa-sha256; cv=none; b=PWsXKJ1yutiUk6T5VIASi5K9NT0upGXDJdiKdKfKYGCwzDVlAz+N9wPk7+qIcXCOc4Nbl3 6wUCTQW56UjOzJLB+9bdGKB/WZttI+GPbGXYG6sVZS+WlOYTXeJJzSYDBuUTnuJTz0jss3 DPEG4lDIOABoLSbkICDWB7KT89JY9y0= X-Stat-Signature: n1gatxwpphwe4sszc1skjyo4pdgby6as X-Rspamd-Server: rspam09 X-Rspam-User: Authentication-Results: imf19.hostedemail.com; dkim=none; dmarc=none; spf=pass (imf19.hostedemail.com: domain of mgorman@techsingularity.net designates 46.22.136.242 as permitted sender) smtp.mailfrom=mgorman@techsingularity.net X-Rspamd-Queue-Id: A2E281A0024 X-HE-Tag: 1665476735-825761 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Oct 10, 2022 at 10:45:43PM +0200, Vlastimil Babka wrote: > On 10/10/22 16:22, Mel Gorman wrote: > > On Wed, Aug 24, 2022 at 10:58:26PM -0600, Yu Zhao wrote: > > > On Wed, Aug 24, 2022 at 8:18 AM Mel Gorman wrote: > > > > > > > > The pcp_spin_lock_irqsave protecting the PCP lists is IRQ-safe as a task > > > > allocating from the PCP must not re-enter the allocator from IRQ context. > > > > In each instance where IRQ-reentrancy is possible, the lock is acquired using > > > > pcp_spin_trylock_irqsave() even though IRQs are disabled and re-entrancy > > > > is impossible. > > > > > > > > Demote the lock to pcp_spin_lock avoids an IRQ disable/enable in the common > > > > case at the cost of some IRQ allocations taking a slower path. If the PCP > > > > lists need to be refilled, the zone lock still needs to disable IRQs but > > > > that will only happen on PCP refill and drain. If an IRQ is raised when > > > > a PCP allocation is in progress, the trylock will fail and fallback to > > > > using the buddy lists directly. Note that this may not be a universal win > > > > if an interrupt-intensive workload also allocates heavily from interrupt > > > > context and contends heavily on the zone->lock as a result. > > > > > > Hi, > > > > > > This patch caused the following warning. Please take a look. > > > > > > Thanks. > > > > > > WARNING: inconsistent lock state > > > 6.0.0-dbg-DEV #1 Tainted: G S W O > > > -------------------------------- > > > > I finally found time to take a closer look at this and I cannot reproduce > > it against 6.0. What workload triggered the warning, on what platform and > > can you post the kernel config used please? It would also help if you > > can remember what git commit the patch was tested upon. > > > > Thanks and sorry for the long delay. > > I didn't (try to) reproduce this, but FWIW the report looked legit to me, as > after the patch, pcp_spin_trylock() has to be used for both allocation and > freeing to be IRQ safe. free_unref_page() uses it, so it's fine. But as the > stack trace in the report shows, free_unref_page_list() does pcp_spin_lock() > and not _trylock, and that's IMHO the problem. > I completely agree, it was a surprise to me that IO completion would happen in soft IRQ context even though blk_done_softirq indicates that it is normal and I didn't manage to trigger that case myself. I wondered if there was an easy way to force that which would have made testing of this easier. I can live without the reproduction case and cc Yu Zhao after 6.1-rc1 comes out and I've fixed this. -- Mel Gorman SUSE Labs