Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp4973004rwb; Tue, 17 Jan 2023 07:41:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXt1Ji72hGqUdHJhD8PR7tITe18Y3ZXoaqUyVfFiLnS3QhnUfD+DFz9p0pLKoIJ+a18iNpbn X-Received: by 2002:a05:6a20:b289:b0:b8:77a6:5afb with SMTP id ei9-20020a056a20b28900b000b877a65afbmr3312881pzb.28.1673970086012; Tue, 17 Jan 2023 07:41:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673970085; cv=none; d=google.com; s=arc-20160816; b=yD4MZxGsy9xo8oWLChh186msSWqGT0dhHNlED+8V08pqKlSW6I790Jjy6W9RIhUrc0 jLJSfjB2x4ymSWH1AdQ1iVA8Z0oZ3lM5DSJhhLzKCL9wyCno1oY0KSuWh9aACXOfKPhw +CkRXltTpzL1Um49vNKz/ApgaMwA4uv4cL7ix+D+REdQKSpANNu49LP7qJI9jgG2fgC3 IWBPDlz1ykB07GzGdkGsUT3443TrPVGL9Gz3Y6QE81n8/j/34bX5jg9XFifXfo2JD3M0 PU/3ZZD+sb/yiRYsbXjMX3jexwIGxzVosb5kmkTsK/UPh2rD/eUS6Lh0pgyEoBwiLjVv sg5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4A2lQI6oPlYBll6FagjI+6K6oYf8bDJMQjbWKre5gTs=; b=blCHgJeeW12I9QT1Q7DWMuxBwgiBXMf/A0qN+OCZHg1kq6LPqWe+fC+C21JZ3xJc/+ gya/kyGMHX1tNHp0mU4YYFJTLeHIMWkHgaTRLO54BHEEk7hx6fOiQA+nHISppa8rxbF0 EWbSy/BVIJQuI8JIE8OyV4lfBV22NyPSQvBlAPCACSBEqR4ciVJPfTEHGJUQiG276pN+ V2GPfAfPJyrF/lKNSwWdp4RyqiCu3snj9ttlsatO64dluiGhp0bqxz6+lTbg/j6c5dSh 5gLdO01bvQ9gJc/DJH4DZ6cLeR9e3QVS3wqZ/m+mlGFM8BN47pztTe+LGr4naDzRLF/F sspQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="aE/49OXp"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k133-20020a636f8b000000b004c1c7333698si15121698pgc.804.2023.01.17.07.41.20; Tue, 17 Jan 2023 07:41:25 -0800 (PST) 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=@suse.com header.s=susede1 header.b="aE/49OXp"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231458AbjAQP01 (ORCPT + 48 others); Tue, 17 Jan 2023 10:26:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231543AbjAQPZv (ORCPT ); Tue, 17 Jan 2023 10:25:51 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B150D212B for ; Tue, 17 Jan 2023 07:25:49 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 5542B68958; Tue, 17 Jan 2023 15:25:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1673969148; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4A2lQI6oPlYBll6FagjI+6K6oYf8bDJMQjbWKre5gTs=; b=aE/49OXp41VQnDrTt6SKcz5FlXnNqrOPUHyWOX1H3m/FJBp55zLq74suwTWgIwxhBKHxAG KyFsmq6H+sy7YptkgzmYBAWOTsBTYf9Ws1usg6QIQiMdr0Qqs2H0yBiw6g+RMPDVjGGh9j IXQlzjpu2YyY8kbttGAm+gcJNvI0dsQ= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2BCD51390C; Tue, 17 Jan 2023 15:25:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id /zdYCvy9xmNkSwAAMHmgww (envelope-from ); Tue, 17 Jan 2023 15:25:48 +0000 Date: Tue, 17 Jan 2023 16:25:47 +0100 From: Michal Hocko To: Suren Baghdasaryan Cc: akpm@linux-foundation.org, michel@lespinasse.org, jglisse@google.com, vbabka@suse.cz, hannes@cmpxchg.org, mgorman@techsingularity.net, dave@stgolabs.net, willy@infradead.org, liam.howlett@oracle.com, peterz@infradead.org, ldufour@linux.ibm.com, laurent.dufour@fr.ibm.com, paulmck@kernel.org, luto@kernel.org, songliubraving@fb.com, peterx@redhat.com, david@redhat.com, dhowells@redhat.com, hughd@google.com, bigeasy@linutronix.de, kent.overstreet@linux.dev, punit.agrawal@bytedance.com, lstoakes@gmail.com, peterjung1337@gmail.com, rientjes@google.com, axelrasmussen@google.com, joelaf@google.com, minchan@google.com, jannh@google.com, shakeelb@google.com, tatashin@google.com, edumazet@google.com, gthelen@google.com, gurua@google.com, arjunroy@google.com, soheil@google.com, hughlynch@google.com, leewalsh@google.com, posk@google.com, linux-mm@kvack.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, x86@kernel.org, linux-kernel@vger.kernel.org, kernel-team@android.com Subject: Re: [PATCH 18/41] mm/khugepaged: write-lock VMA while collapsing a huge page Message-ID: References: <20230109205336.3665937-1-surenb@google.com> <20230109205336.3665937-19-surenb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230109205336.3665937-19-surenb@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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 Mon 09-01-23 12:53:13, Suren Baghdasaryan wrote: > Protect VMA from concurrent page fault handler while collapsing a huge > page. Page fault handler needs a stable PMD to use PTL and relies on > per-VMA lock to prevent concurrent PMD changes. pmdp_collapse_flush(), > set_huge_pmd() and collapse_and_free_pmd() can modify a PMD, which will > not be detected by a page fault handler without proper locking. I am struggling with this changelog. Maybe because my recollection of the THP collapsing subtleties is weak. But aren't you just trying to say that the current #PF handling and THP collapsing need to be mutually exclusive currently so in order to keep that assumption you have mark the vma write locked? Also it is not really clear to me how that handles other vmas which can share the same thp? -- Michal Hocko SUSE Labs