Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2248298rwl; Thu, 6 Apr 2023 07:46:41 -0700 (PDT) X-Google-Smtp-Source: AKy350ajlZF0I2fFp9r3UuMeb6cCsbWEVseXFlhbyWD8JaWnaHPUWDOBQ9UDud209OfcXAR5Qz85 X-Received: by 2002:a17:906:b293:b0:947:71bf:ca19 with SMTP id q19-20020a170906b29300b0094771bfca19mr6909340ejz.65.1680792401031; Thu, 06 Apr 2023 07:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680792401; cv=none; d=google.com; s=arc-20160816; b=yUXwGIMlLGdbdkFBkoZTbtio/GkKKrOaO+0tZiIgt49QW4hRhSk0xYUebj/eC6BImb Siz58GIG0QEu/FjetmDGVQv4lzLntWaW/75p3ULw8cgft/kE65U6rjWh5qFNAB7azDBt 0B4BicK4Y9bQ1smroMtyI6bc5BKSbI+GMD/HKbNw1DNsVqvEVg+U4BPsEFgMMraIO3hv aKV068q4287FCgEDgwWrr6Ww1N/KMfiWK2nkcdWHeFnq7JmJHWjkSzzUueNuA5LWIRhs sRZ/V3D1lT7ZwZwAuTxZWHbEuulXM4Z0FcVmu4ZpW4oT9nkC+PZZr2VblgWWB+enPj7L hq5w== 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:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=gj/7YiiNEEJ4+hsVKCJkj1HvadHLyL0uUxvEtZRASmc=; b=AqEHddNWhTXnFCYjGrvkniBSOHzfgeg1+WlQDjOMJnYk0m1EbyLdvch1xIkT+dqfaV jqVrFHamrcs20t/1cNpx4DGwheCfXivXVDphNgZ6ziEY7p+XGoBoWv2uo/jLUeM32Zul W1g04x/+K3r/Ln8alMw1YZ5fd1qUp3whuQ8rhH680sWk9lLD+ODyA5NDhHMipKX09BCg 7zwNC83grT8UkZ4yqlaK/U+KqPXwN/BzuquAC2KQ+oCb+zqo1Xnt0GVgmKOJ+H47mODd Z7oQJnqd+tcV/bO634xlA9WGKoaLq1MTzGiL+J64KB16pMNSklLckXtzO/r8WB3qhDh1 ZbGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MFH7ILfx; 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 e18-20020a1709062c1200b00949881147e9si1200586ejh.327.2023.04.06.07.46.15; Thu, 06 Apr 2023 07:46:41 -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=MFH7ILfx; 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 S239373AbjDFOoI (ORCPT + 99 others); Thu, 6 Apr 2023 10:44:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237735AbjDFOnt (ORCPT ); Thu, 6 Apr 2023 10:43:49 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2A01C5 for ; Thu, 6 Apr 2023 07:42:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680792128; 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=gj/7YiiNEEJ4+hsVKCJkj1HvadHLyL0uUxvEtZRASmc=; b=MFH7ILfxbxZqwO0kUF9n0x6w2yOBze1MxGq/VEeatz4ioSpLISS87DxB3FDvicAARR+9QA s51Ge5pm9TdLPJglEADJtgBgdA4ozmMs2yKsILr6cyhqVmd86lXUWM4E+u/lLbT2p3E3tI QkYVLP3BjATwNTZLVt1NF8ymBEekAZo= 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.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-VDLEM4zzNR28FmzVQ0vglw-1; Thu, 06 Apr 2023 10:42:07 -0400 X-MC-Unique: VDLEM4zzNR28FmzVQ0vglw-1 Received: by mail-wr1-f71.google.com with SMTP id e15-20020adfa44f000000b002d7ea9d6ef0so4937644wra.8 for ; Thu, 06 Apr 2023 07:42:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680792126; x=1683384126; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gj/7YiiNEEJ4+hsVKCJkj1HvadHLyL0uUxvEtZRASmc=; b=jw90hN/W24tC+aS/lKqA0aUb5wuAkVlr516y1uMZoVnYCXfRS+cTWHwFPiqrzVeXWe X2BE5TVu76uhrebtxhlAWe+O9xZocpuYWMl6r+8NT7AVE7OxDHnemg/YG75VVWbR+SLc gDd/993wU9g9Koexi2C1P4Yznsam5RUra+5QZpbLql8gMqesc5bCTGaoEVDuGkMdyZ4T aV8CT+g3YLy6q7/5e9i96ViPj3+Q0U1mvY61x+P9CEg8NacZpInE1ybXVWVeAcKrDgku uyTmQUZFgvDqQmJnzsAQXy3HnDpxoX2PDCtcsWcSdDy/U7br06qrZD5jttuiNeqlY4Gr Jijw== X-Gm-Message-State: AAQBX9d4cWvt6OjO3ComxTM+kVTgHWdtDEaJHzjYBUQy9dIJTj4ooc7u iAXRDJes2m2458PordQgZYv7yGzMPMa95vSkCnD8sDOZUT16uTOTPXW52J6NzAibtaWg6YQTDPG GfMld2oqeYeNKSQqbUKYE1p8g X-Received: by 2002:adf:edd1:0:b0:2cf:e436:f722 with SMTP id v17-20020adfedd1000000b002cfe436f722mr7362230wro.64.1680792125937; Thu, 06 Apr 2023 07:42:05 -0700 (PDT) X-Received: by 2002:adf:edd1:0:b0:2cf:e436:f722 with SMTP id v17-20020adfedd1000000b002cfe436f722mr7362204wro.64.1680792125568; Thu, 06 Apr 2023 07:42:05 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:5dac:bf3d:c41:c3e7? ([2a09:80c0:192:0:5dac:bf3d:c41:c3e7]) by smtp.gmail.com with ESMTPSA id m8-20020adffe48000000b002c55521903bsm1942945wrs.51.2023.04.06.07.42.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Apr 2023 07:42:04 -0700 (PDT) Message-ID: <1654e2d5-5a32-a253-e335-0ee42f69f5ef@redhat.com> Date: Thu, 6 Apr 2023 16:42:02 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: Peter Zijlstra , Marcelo Tosatti Cc: Frederic Weisbecker , Yair Podemsky , linux@armlinux.org.uk, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, borntraeger@linux.ibm.com, svens@linux.ibm.com, davem@davemloft.net, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, will@kernel.org, aneesh.kumar@linux.ibm.com, akpm@linux-foundation.org, arnd@arndb.de, keescook@chromium.org, paulmck@kernel.org, jpoimboe@kernel.org, samitolvanen@google.com, ardb@kernel.org, juerg.haefliger@canonical.com, rmk+kernel@armlinux.org.uk, geert+renesas@glider.be, tony@atomide.com, linus.walleij@linaro.org, sebastian.reichel@collabora.com, nick.hawkins@hpe.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, vschneid@redhat.com, dhildenb@redhat.com, alougovs@redhat.com, jannh@google.com References: <20230404134224.137038-1-ypodemsk@redhat.com> <20230404134224.137038-4-ypodemsk@redhat.com> <20230405195226.GB365912@hirez.programming.kicks-ass.net> <20230406132928.GM386572@hirez.programming.kicks-ass.net> <20230406140423.GA386634@hirez.programming.kicks-ass.net> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH 3/3] mm/mmu_gather: send tlb_remove_table_smp_sync IPI only to CPUs in kernel mode In-Reply-To: <20230406140423.GA386634@hirez.programming.kicks-ass.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 06.04.23 16:04, Peter Zijlstra wrote: > On Thu, Apr 06, 2023 at 03:29:28PM +0200, Peter Zijlstra wrote: >> On Thu, Apr 06, 2023 at 09:38:50AM -0300, Marcelo Tosatti wrote: >> >>>> To actually hit this path you're doing something really dodgy. >>> >>> Apparently khugepaged is using the same infrastructure: >>> >>> $ grep tlb_remove_table khugepaged.c >>> tlb_remove_table_sync_one(); >>> tlb_remove_table_sync_one(); >>> >>> So just enabling khugepaged will hit that path. >> >> Urgh, WTF.. >> >> Let me go read that stuff :/ > > At the very least the one on collapse_and_free_pmd() could easily become > a call_rcu() based free. > > I'm not sure I'm following what collapse_huge_page() does just yet. It wants to replace a leaf page table by a THP (Transparent Huge Page mapped by a PMD). So we want to rip out a leaf page table while other code (GUP-fast) might still be walking it. In contrast to freeing the page table, we put it into a list where it can be reuse when having to PTE-map a THP again. Now, similar to after freeing the page table, someone else could reuse that page table and modify it. If we have GUP-fast walking the page table while that is happening, we're in trouble. So we have to make sure GUP-fast is done before enqueuing the now-free page table. That's why the tlb_remove_table_sync_one() was recently added (by Jann IIRC). -- Thanks, David / dhildenb