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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A52BAC433F5 for ; Wed, 15 Dec 2021 16:07:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PZ3rmVrw/r/Zz4/oHKxO8FV25idnX/mX3hIsAJl7H2Q=; b=daUTnxyqgtOedJ ulOu8yOfYzVjHnHhyug220CupB0bmqWsAUcza4HiPKOpMsVX2/ZUMiUrFm+UHrBsvifSYeDAU2tWb qSFlRT60PNKh8DwZR1W3QMhSL9QgjqH4FXIxrFaIWDPzMU0KnZ6UsxSTOpZWmeAFHxiVh7Sws4JIO 47EvJg12jH90WFj1zuefVBRUSDLqiBw0iVRojDO5l+dNhYcxc85rggS7KabmcL1SFscz8MSFYFhM3 tZtzcMlySZFLx32xxshRfvOpyd5VNHOSBkCQmOhQdonO5+rEOgrEzmb+xEkviUFZskBM66zyTj1vN r9QnINLJTiwpnnd3n61Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxWmp-001YUV-0C; Wed, 15 Dec 2021 16:05:47 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mxWlT-001Xjs-RH for linux-arm-kernel@lists.infradead.org; Wed, 15 Dec 2021 16:04:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639584262; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5+qkhOLxZwUCzoouW57Nu2zO8Pbzn2kT/DzdHBiJ+XI=; b=BE57gNlEk9ryR92kLKSe3lzp5Iss+xg7XomfgAzcDb9K/gBZOA1zhU1yXLCdXoItYYfOtr AwKnI1Gd6NZcDZwxAQmFcN5t7E5/AByS8GMvKzuvZXCx5CN2QSTZhcJoJkhrrm+OSR8Xup v5mFW9ecZ83UyBGuE/xTx7AXe8G8NJg= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-321-6UieERIbPWWNVwJER3Fgqg-1; Wed, 15 Dec 2021 11:04:21 -0500 X-MC-Unique: 6UieERIbPWWNVwJER3Fgqg-1 Received: by mail-wm1-f71.google.com with SMTP id 205-20020a1c00d6000000b003335d1384f1so14858178wma.3 for ; Wed, 15 Dec 2021 08:04:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=5+qkhOLxZwUCzoouW57Nu2zO8Pbzn2kT/DzdHBiJ+XI=; b=iDAcOeyUew60VC/FZuoLkhKDv6sOjsDrMbAmoleMls3VXtN9oDEiLAtWdWbgbt3Y7F L4/MqGF7U37H/Xxr3K3vUYGz1te/oY97IS01DU4F99o1EnZGIK3POU9Vp4nl3IslOjgI B0SMQL6z/yGIs7K9TMgXK9EiR+SU6MVBfsau9oPz2JBpzQcCqXob9ss9gr4eQaLvZnN5 Q0/d+RpabG5w0q4+AzZGYUiUacpf6eRLsHcsacpR/GIr79ZiRhZW5P5CueWrkL7IEVRD ydtaL5TshP+ozYmTLNjS12dj8U/Tho7GuGKOsKp7UWZIDBELSI8VxkLe0VI9WCZkvVHi Qp4g== X-Gm-Message-State: AOAM5308/KtIwlI+VJHHX5ZvM9x5Qs0AuUrGgdHqQ66hkzHNAJ6p/4Sn ytUsIRIHY8zDliNqaSuA4St+yO04sZGAKGSzhsyZS6jPjpotRbvIO0qqkGFNZEGB6sn44ayx9LI Zy5+404XDiYgpghsNa3eD2EGf+tlKWv1Feo4= X-Received: by 2002:a1c:a905:: with SMTP id s5mr476584wme.85.1639584260226; Wed, 15 Dec 2021 08:04:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8+iToR5ZFLyprHiWIwROYMdO2owpbxyBW2o4XlxWdG53Y5ecviQglm6t+MNmZqfkKYVXoiw== X-Received: by 2002:a1c:a905:: with SMTP id s5mr476565wme.85.1639584260043; Wed, 15 Dec 2021 08:04:20 -0800 (PST) Received: from [192.168.3.132] (p5b0c609b.dip0.t-ipconnect.de. [91.12.96.155]) by smtp.gmail.com with ESMTPSA id b6sm6684752wmq.45.2021.12.15.08.04.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Dec 2021 08:04:19 -0800 (PST) Message-ID: Date: Wed, 15 Dec 2021 17:04:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH v2] arm64/mm: avoid fixmap race condition when create pud mapping To: Catalin Marinas , Qian Cai Cc: Jianyong Wu , will@kernel.org, anshuman.khandual@arm.com, akpm@linux-foundation.org, ardb@kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gshan@redhat.com, justin.he@arm.com, nd@arm.com References: <20211210095432.51798-1-jianyong.wu@arm.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=david@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211215_080424_032602_262C7731 X-CRM114-Status: GOOD ( 16.41 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 15.12.21 17:02, Catalin Marinas wrote: > On Wed, Dec 15, 2021 at 09:13:37AM -0500, Qian Cai wrote: >> On Fri, Dec 10, 2021 at 05:54:32PM +0800, Jianyong Wu wrote: >>> fixmap is a global resource and is used recursively in create pud mapping. >>> It may lead to race condition when alloc_init_pud is called concurrently. >>> >>> Fox example: >>> alloc_init_pud is called when kernel_init. If memory hotplug >>> thread, which will also call alloc_init_pud, happens during >>> kernel_init, the race for fixmap occurs. >>> >>> The race condition flow can be: >>> >>> *************** begin ************** >>> >>> kerenl_init thread virtio-mem workqueue thread >>> ================== ======== ================== >>> alloc_init_pud(...) >>> pudp = pud_set_fixmap_offset(..) alloc_init_pud(...) >>> ... ... >>> READ_ONCE(*pudp) //OK! pudp = pud_set_fixmap_offset( >>> ... ... >>> pud_clear_fixmap() //fixmap break >>> READ_ONCE(*pudp) //CRASH! >>> >>> **************** end *************** >>> >>> Hence, a spin lock is introduced to protect the fixmap during create pdg >>> mapping. >>> >>> Signed-off-by: Jianyong Wu >> >> I am afraid there is a problem to take a spinlock there. >> >> node 0 deferred pages initialised in 2740ms >> pgdatinit0 (176) used greatest stack depth: 59184 bytes left >> devtmpfs: initialized >> KASLR disabled due to lack of seed >> BUG: sleeping function called from invalid context at mm/page_alloc.c:5151 > > Thanks for the report. Definitely a bug, GFP_KERNEL_ACCOUNT allows for > the page allocator to sleep. I'll drop the patch from the arm64 > for-next/fixes branch for now and sort it out later. > Sounds like we need a mutex then. -- Thanks, David / dhildenb _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel