Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4580330imw; Tue, 19 Jul 2022 09:12:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uxg5kVnU1nb0k2GTnBbgZvh3jBLdqmDqK90Ic7VK4hlx+nfmFysWjsXvDIzP4GXLBY8mpy X-Received: by 2002:a05:6402:2554:b0:43a:902b:d31f with SMTP id l20-20020a056402255400b0043a902bd31fmr44661370edb.416.1658247135375; Tue, 19 Jul 2022 09:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658247135; cv=none; d=google.com; s=arc-20160816; b=x9hjlHaPfBwz2xI9HdxP27fKURIlXvwQnqM68cr9D+i2pUNARBptu5pFStxhddXByt YBZx7PBlKKlDtxbGjrZ/jnOdlhlt1X1Icv2MbL/PYz+8v7bF2xOzS2jTH3x6swMyadMI rkfcRUI2JdkaqQk+OU5a5artjCU66XDF4sCFQV6sTcowbA2mDvqy04ioPsrF57sVV3bb MifT7SrXT7Qvr36xOpIgy3kr1hqF1IXJe1HmyAe1Ln/D+JOsvWrJtPqJeEOn16m37L7K Yt00boWD17RuDa95yAzoCMOt6t9G8OaniM5Gr6aDLzs1AbrnJIjcWMSwfr2+HyShYflj WlLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=uDy3s2QOPJGPftDZNgnW2ktTSjzkXRv57+Dqh8lp+dc=; b=kGXWsa9DKWAvWj1ca5Tu5soFsZpr4Qxhp+U2xsOOstuGjtNvWl/fF26s/Nbe+H71AV Q82C9cCwmEjp628Ae3kNIsXi81VVdNYnc7yyly5ATaVE65u9W2IgttyWm0/AtA8ehfoI NLFO1UeNa65VrOhm1e0tXALWLJveelsaxaYuaDwdS/wJYd8HhivUZ2RBa7/Ddfj9qr8g 0BSecgXtObbebHMA4OTK4cphVcJZVQ/OLhejcx29poTvJc1pzMT1+NEwFPVTSeHLWeli 7fiRJkSdz7qCUf1Yy9c2JLQNp5VV4QWmLmgL0KTwQ4nJqI7jip/uVmiIBcrD/90725QC ubZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NTew3wUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k24-20020a508ad8000000b0043ba3b52d3dsi1347526edk.412.2022.07.19.09.11.50; Tue, 19 Jul 2022 09:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NTew3wUH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239475AbiGSPyW (ORCPT + 99 others); Tue, 19 Jul 2022 11:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239577AbiGSPyM (ORCPT ); Tue, 19 Jul 2022 11:54:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8D9C55019B for ; Tue, 19 Jul 2022 08:54:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658246050; 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=uDy3s2QOPJGPftDZNgnW2ktTSjzkXRv57+Dqh8lp+dc=; b=NTew3wUHeMz2u/uvLykcK8UNMhb+NGQvY/ZyojtlNIqWmSBPfuwINefZme0/M54k+/7zVu ZWoLAT7lTrcYzUueJiZjL5906hHrJ0i1QGdDDp+Mt9Z43MyUsKp9Z4n8whKKCFI5rYf6nb smk69unat1PRnFWTMfTjDQvF8CTf1yI= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-570-m17xOo9jO1uycoHe6QyV8A-1; Tue, 19 Jul 2022 11:54:09 -0400 X-MC-Unique: m17xOo9jO1uycoHe6QyV8A-1 Received: by mail-wm1-f70.google.com with SMTP id n18-20020a05600c501200b003a050cc39a0so6958759wmr.7 for ; Tue, 19 Jul 2022 08:54:09 -0700 (PDT) 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=uDy3s2QOPJGPftDZNgnW2ktTSjzkXRv57+Dqh8lp+dc=; b=4/JGXnDknEGAIno1Ekr0Crj8aGIW+GcVxhgF6XQms71pokUjfBvPMmoxIVxzS/5ulP trFbEpXP2LOR7D+X9CfW8IWBP/N0UjO3cGSwtnOwE9YMNzrfWh1uzvCegJA6QOIsCIdN H4qNX6yG4FDStDd4ZPF+NkiPIsxgjJ96RLS3XXzFSGaBfrm/7E3zvFPXd8e2dUuIgbno P6IoL/GfWw7rA3hOUdTs53o17n6Oc9ZiSa1TLgevgRGmBRzzfJN4FKKTaet9ek1bOu53 Y0G+v800DHerhyHkz0pgXKhb9h1yqGwoXxg057LcgPwdQCJtM19hH1tClYGzse/dV77n T/kg== X-Gm-Message-State: AJIora+y5qDzJ9uJyEpQyGoggfVKGRvxhe8JOl3yfTR1Rz+CAMyGHQoC UjOh66wScj4w8ShT3d++XgfF6RKMTu7iJzbGSrVrmeqcEN0aV53f//19RfKG03jM1RNEqxVjYei 6okTFBBsBh/+dzcA15f0IQQxJ X-Received: by 2002:a05:6000:49:b0:21d:78fe:34b2 with SMTP id k9-20020a056000004900b0021d78fe34b2mr26645039wrx.200.1658246048064; Tue, 19 Jul 2022 08:54:08 -0700 (PDT) X-Received: by 2002:a05:6000:49:b0:21d:78fe:34b2 with SMTP id k9-20020a056000004900b0021d78fe34b2mr26645023wrx.200.1658246047808; Tue, 19 Jul 2022 08:54:07 -0700 (PDT) Received: from ?IPV6:2003:cb:c709:600:7807:c947:bc5a:1aea? (p200300cbc70906007807c947bc5a1aea.dip0.t-ipconnect.de. [2003:cb:c709:600:7807:c947:bc5a:1aea]) by smtp.gmail.com with ESMTPSA id p42-20020a05600c1daa00b003a30f84a9aasm14803515wms.26.2022.07.19.08.54.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Jul 2022 08:54:07 -0700 (PDT) Message-ID: <7a77f387-9400-3b41-d89f-2f1ef7bfbdc4@redhat.com> Date: Tue, 19 Jul 2022 17:54:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] mm: fix use-after free of page_ext after race with memory-offline Content-Language: en-US To: Michal Hocko , Charan Teja Kalla Cc: akpm@linux-foundation.org, pasha.tatashin@soleen.com, sjpark@amazon.de, sieberf@amazon.com, shakeelb@google.com, dhowells@redhat.com, willy@infradead.org, vbabka@suse.cz, minchan@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, "iamjoonsoo.kim@lge.com" , Pavan Kondeti References: <1657810063-28938-1-git-send-email-quic_charante@quicinc.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19.07.22 17:43, Michal Hocko wrote: > On Tue 19-07-22 20:42:42, Charan Teja Kalla wrote: >> Thanks Michal!! >> >> On 7/18/2022 8:24 PM, Michal Hocko wrote: > [...] >>>>>> diff --git a/mm/page_ext.c b/mm/page_ext.c >>>>>> index 3dc715d..5ccd3ee 100644 >>>>>> --- a/mm/page_ext.c >>>>>> +++ b/mm/page_ext.c >>>>>> @@ -299,8 +299,9 @@ static void __free_page_ext(unsigned long pfn) >>>>>> if (!ms || !ms->page_ext) >>>>>> return; >>>>>> base = get_entry(ms->page_ext, pfn); >>>>>> - free_page_ext(base); >>>>>> ms->page_ext = NULL; >>>>>> + synchronize_rcu(); >>>>>> + free_page_ext(base); >>>>>> } >>>>> So you are imposing the RCU grace period for each page_ext! This can get >>>>> really expensive. Have you tried to measure the effect? >>> I was wrong here! This is for each memory section which is not as >>> terrible as every single page_ext. This can be still quite a lot memory >>> sections in a single memory block (e.g. on ppc memory sections are >>> ridiculously small). >>> >> >> On the ARM64, I see that the minimum a section size will go is 128MB. I >> think 16MB is the section size on ppc. Any inputs on how frequently >> offline/online operation is being done on this ppc arch? > > I have seen several reports where 16MB sections were used on PPC LPARs > with a non trivial size. My usual answer to that is tha this is mostly a > self inflicted injury but I am told that for some reasons I cannot > udnerstand this is not easy to change. So reasonable or not this is not > all that uncommon in PPC land. > > We definitely shouldn't optimize for those setups but we shouldn't make > them suffer even more as well. Besides that it seems that a single > rcu_synchronize per offline operation should be doable. IIRC, any reasonable PPC64 installation uses LMB >= 256 MiB, which maps to the logical memory block size, and we only online/offline complete memory blocks, not individual memory sections. So one these installations, you'll see memory getting onlined/offlined in at least 256MiB granularity. -- Thanks, David / dhildenb