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 84527C43334 for ; Tue, 19 Jul 2022 15:54:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 06F6D6B0074; Tue, 19 Jul 2022 11:54:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F39F96B0075; Tue, 19 Jul 2022 11:54:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB32D6B0078; Tue, 19 Jul 2022 11:54:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C68916B0074 for ; Tue, 19 Jul 2022 11:54:11 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 9CDF61C5B3E for ; Tue, 19 Jul 2022 15:54:11 +0000 (UTC) X-FDA: 79704295902.15.EBA18A2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 3F98618005A for ; Tue, 19 Jul 2022 15:54:11 +0000 (UTC) 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-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-280-wTqi27QcNGK0aOAu2Kw3lw-1; Tue, 19 Jul 2022 11:54:09 -0400 X-MC-Unique: wTqi27QcNGK0aOAu2Kw3lw-1 Received: by mail-wr1-f71.google.com with SMTP id l5-20020adfa385000000b0021db73f5818so2735419wrb.20 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=F2+9GHMDLVDIQgbMMncA5WMmUcWG6ovW9f9Woo3gcJd1vWtdA9W8gQIlCbHSqlH+jO mZrMnCtBRBQHEhh6JGeC/uO6Q0fw304hcvRQP9GVPdHhGkSwj4CsiIPiR5MW72vnQv1G 1TotjnSuoujW61Uhi8lO9efBs4yh2JIbJoAv7bojpIWprfZgPG0JgwUv2VpfVu90Xfdk O8H4S+hEIZ4OTvd2UtHix/h6+3+UsLvc0X7Z5mD16zKEI3ju4vVfSi3DXGLpge0Yd/lP a5DQ8/IL8hI+PonLTeis+0Q2kQyhgV6efd2XkgIXXlwC0o0JbOVN5MxiNyA2p2MTc0Y1 Z1fQ== X-Gm-Message-State: AJIora+7FWxAGUBaAZQg794msmH3SSh71yOu0DtGlIqjF9Mju3GIBhLU CcE9pUhRmv7cv0+0AfrOrhTbLIvL6A+65ClMjMIx2UONr7dPlGRaJHz7bcsZubAIlOALhaCQYK+ nAT5qDRQe/Is= X-Received: by 2002:a05:6000:49:b0:21d:78fe:34b2 with SMTP id k9-20020a056000004900b0021d78fe34b2mr26645049wrx.200.1658246048066; Tue, 19 Jul 2022 08:54:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tCgEneS8qXFTHOg4Z/NJV6IoJyNYt2ANrLuhZ2wKTFrfyj//ZS6x2HbMBQ7sJIZ5gFAGIUQA== 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 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: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1658246051; a=rsa-sha256; cv=none; b=6CjTFenruhNt0+IeLVsKDI9eISdXxKeH3OraN9N/OsB7R9+IYXjVFYLFHB3+lIKX2Wzs4a 4LOE7Yc2ao0i+mYFfb0sDx6ANqSg1WQ6UdryonQUwlkGZZY7nsvyZlNZXtgHgzJ7TXEvDR XsIEqO68zbvPcygKOPA92UC1x3n1KnY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NTew3wUH; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1658246051; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uDy3s2QOPJGPftDZNgnW2ktTSjzkXRv57+Dqh8lp+dc=; b=bIqbPxvozTBNCcQt75GONS2XJ7uQLWKJvPc/yEfvglyvxyL5lBrPKbmkmsIT8vUsQ7mTQB EdrXa/WGBzCS4GkOT77jBj+VtHeK1Zyyr9vcWBUQMFJrQUG7gVNCbKQHXkcv47QZdDfDQH TNGefy7NLNMBhraXocKnPqp4FCNaEu8= X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NTew3wUH; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf06.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com X-Stat-Signature: b84n5nuqci6wut5c7xcr7j48npjopari X-Rspamd-Queue-Id: 3F98618005A X-Rspamd-Server: rspam02 X-HE-Tag: 1658246051-251248 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 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