Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4651793rwi; Mon, 17 Oct 2022 08:57:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7iwsEbPuaMrtadJyDVTFS3+NY8p+jvSTCSK72n8EJj0i/liVOVyf38r6gSN2mtZa+FeVI9 X-Received: by 2002:a17:907:a46:b0:782:1c1c:8141 with SMTP id be6-20020a1709070a4600b007821c1c8141mr9190047ejc.549.1666022236347; Mon, 17 Oct 2022 08:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666022236; cv=none; d=google.com; s=arc-20160816; b=EWQb3Mo7zsErb/rrVGWc2lG9a8GVlYsYLFmxuOPJVRZUXRuY4OTtclnulZN0Bjm/UU HPdbhi9TrqG+C/3u5oAA27uCUNq8ySvT1dUogmLMJa/2XS/basC+RfS8OTDU1U6Fz8E8 APOmJcTRS/rHYbq9TUF2dtOq/bXUXBA6/dPjt8HnzIDmin40HlHzpy0ssuypQmnqQ99r 6RevFD+XsrrJMAT0z1XoFo7HkEzpw3YuRFyWzbesfTcXq/yjYTbu02fF7a8QGAuBQHHA owDWQ6YNNexxEpyHlRLlI0/UCqzu2/T4EiGIbt7iuAjaYjeoZvTsgpwF5CZF+1Btd/kn ftpw== 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 :dkim-signature; bh=YwPRndPIKbMGfHiI0+b6VWLwGq2HJgw8Lxgojln60d0=; b=msBv+wb4G3gqX1VMf2uY5EmDcF2uFdQGkdfwaBysvTPq83XS3NmGTeHG+bxYLdSsJx 1w4sF8i5y7OJgxA0g6sBLhTPpJgAvIm7JLlRGlQJuf4KF/prdTk0WPkjM2Gfx6dF58m0 Rt2FjwallU1MWYnmZL+WMKFIpE4ure3ZSBORURxVsCQ73ogmtfZ9UGZAeyvEh8QnKjxR KM3HwRNGc5cheifg2rJNuyeQ1hVZ+fBy1tsXV1HpQBM8BTJEhbjQjO/3/SvYe+NadGm8 +WUVQYZ7XePLf51ZopqRaIBL1jpBNXHTI2b3rUbC1yYtkNsLlDwmyRUKdfNKSvKkQVLI jiIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=HKcy6ZR4; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a26-20020a17090682da00b0078d9d67841fsi7844254ejy.400.2022.10.17.08.56.49; Mon, 17 Oct 2022 08:57:16 -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=@suse.de header.s=susede2_rsa header.b=HKcy6ZR4; dkim=neutral (no key) header.i=@suse.de; 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=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231303AbiJQPCy (ORCPT + 99 others); Mon, 17 Oct 2022 11:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231560AbiJQPCf (ORCPT ); Mon, 17 Oct 2022 11:02:35 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C3121006D for ; Mon, 17 Oct 2022 08:02:19 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id C102E34302; Mon, 17 Oct 2022 14:57:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1666018640; 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=YwPRndPIKbMGfHiI0+b6VWLwGq2HJgw8Lxgojln60d0=; b=HKcy6ZR4cdX6/c9CqhGRg4sgBXQwSPhSamrRzBggpNOrM/tvut9/JdMLFIUmb5wlS6fPOK uo/3BpWgSmEgh3TH1CfXLT+jL/8jp89dQ2gvllD/ZS+FXc1N0Yia7Zp1urELENWZd+6mpr 0D/ZFHle+DPIACKhWgMYKeRGe14e4Z8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1666018640; 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=YwPRndPIKbMGfHiI0+b6VWLwGq2HJgw8Lxgojln60d0=; b=hmgiBOoEphiWs8FNXs041Qr6u6sF6OybuJeezD2qfhPru+YQzZFSMBHfVKpNbBh3BtTFtp qjVN/enU8IxS1uBQ== Received: from suse.de (mgorman.tcp.ovpn2.nue.suse.de [10.163.32.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id AA9512C141; Mon, 17 Oct 2022 14:57:17 +0000 (UTC) Date: Mon, 17 Oct 2022 15:57:12 +0100 From: Mel Gorman To: Linus Torvalds Cc: Nadav Amit , Jann Horn , Andy Lutomirski , Linux-MM , Rik van Riel , kernel list , Kees Cook , Ingo Molnar , Sasha Levin , Andrew Morton , Will Deacon , Peter Zijlstra Subject: Re: [BUG?] X86 arch_tlbbatch_flush() seems to be lacking mm_tlb_flush_nested() integration Message-ID: <20221017145712.5tdedsrrkbopptzl@suse.de> References: <0484E294-D6D6-45CE-87F7-5AFDA5309BA1@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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 Sat, Oct 15, 2022 at 04:47:16PM -0700, Linus Torvalds wrote: > On Fri, Oct 14, 2022 at 8:51 PM Nadav Amit wrote: > > > > Unless I am missing something, flush_tlb_batched_pending() is would be > > called and do the flushing at this point, no? > > Ahh, yes. > > That seems to be doing the right thing, although looking a bit more at > it, I think it might be improved. > To be fair, I originally got it wrong and Nadav caught it almost 2 years later. However, I think the current behaviour is still ok. > At least in the zap_pte_range() case, instead of doing a synchronous > TLB flush if there are pending batched flushes, it migth be better if > flush_tlb_batched_pending() would set the "need_flush_all" bit in the > mmu_gather structure. > I think setting need_flush_all would miss the case if no PTEs were updated due to a race during unmap. I think it would be safer to check for deferred TLB flush in mm_tlb_flush_nested but didn't dig too deep. > That would possibly avoid that extra TLB flush entirely - since > *normally* fzap_page_range() will cause a TLB flush anyway. > > Maybe it doesn't matter. > While it could be better, I still think the simple approach is sufficient and it can be used in each affected area. For example, move_ptes does not use mmu_gather and either that would have to be converted to use mmu_gather or have mmu_gather and !mmu_gather detection of deferred TLB flushing from reclaim context and I'm not sure it's worth it. Once reclaim is active, the performance is slightly degraded as TLBs are being flushed anyway and it's possible that active pages are being reclaimed that will have to be refaulted which is even more costly. For the scenario Jann was concerned with, pages belonging to the task are being reclaimed while mmap/munmap operations are also happening. munmap/mmap is sufficiently expensive that a spurious flush due to parallel reclaim should have negligible additional overhead and I'd be surprised if the additional runtime cost can be reliably measured. -- Mel Gorman SUSE Labs