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 5CE43C25B76 for ; Wed, 5 Jun 2024 09:11:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D01E76B0089; Wed, 5 Jun 2024 05:10:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CAFD66B008A; Wed, 5 Jun 2024 05:10:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B51546B008C; Wed, 5 Jun 2024 05:10:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 96A9E6B0089 for ; Wed, 5 Jun 2024 05:10:59 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3577912124A for ; Wed, 5 Jun 2024 09:10:59 +0000 (UTC) X-FDA: 82196265438.30.83ADE52 Received: from mail-oo1-f52.google.com (mail-oo1-f52.google.com [209.85.161.52]) by imf06.hostedemail.com (Postfix) with ESMTP id 56DBE18000F for ; Wed, 5 Jun 2024 09:10:57 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KYIQdXFi; spf=pass (imf06.hostedemail.com: domain of seakeel@gmail.com designates 209.85.161.52 as permitted sender) smtp.mailfrom=seakeel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717578657; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=lTG6BM2D9pwAMXwuJmppHUX0zuuxDgXItlRkB2F6Whw=; b=OQduAKsY67fGTdO2WpRUaOMxy0Pjc7H81QDj7XmCNaVFeeYLckW4V/Xg+CMygtcO8mRYF3 XZf22IquAmMcymnBI4qQcG03pJ7nrgSUxKCNsdNqtJwvPplagk5wPm/y1ENuydpT19Y71r iPvwYKCPAfx9RcHE/zMcmS6SvDJ6p9E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717578657; a=rsa-sha256; cv=none; b=pOZ9QFRZfbwtkfJKX0EnCuxc8oesUbtmfWxPCZOj0Js29VQH1YtVZ5BNlQpWG5eFUE7d64 6ZHjOSW1US4NtQZr55zZN9oLdJO6nu4RBslKSFKDBGnG/fC9iHAfsPPXwTmAtftDSy767l ueZPHhHytAgAtlufET6Cuk7zn2XhGD8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=KYIQdXFi; spf=pass (imf06.hostedemail.com: domain of seakeel@gmail.com designates 209.85.161.52 as permitted sender) smtp.mailfrom=seakeel@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-oo1-f52.google.com with SMTP id 006d021491bc7-5b970e90ab8so4168053eaf.3 for ; Wed, 05 Jun 2024 02:10:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717578656; x=1718183456; darn=kvack.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=lTG6BM2D9pwAMXwuJmppHUX0zuuxDgXItlRkB2F6Whw=; b=KYIQdXFivOaperN3YdAN2guGAYPTa77PzM+uePP5cSwZNsc3GUlgb3nOm7bOoGgL3N l/E4sd43FJc+H67PodMAE/MA2HX2FB98+ClEgn227hSRmWyJR5adg5zoF949UgQvWT/6 9Ixk9HfYAjY3G0dEpozrHCqBKSvjITOhAAxeIFgXkAo+ZUWBMnapJ++gp2KqwIKnhW3e 0bdzlAPPYF1MvpJJSDeKBWc/rKwR416sVEOQdJuYQlO7v8OiFz/QYnydiDKTDT5Wuk9b mR4J4O4uVegHWyGz/SmIxowlaqgEdBeuJy38PCC3j4797+Vb0+XnStcgFgLikxJ2Bl+Y aXbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717578656; x=1718183456; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lTG6BM2D9pwAMXwuJmppHUX0zuuxDgXItlRkB2F6Whw=; b=HL+1DpMu5PwYmj9yxt/bpwgje4OZhDi5743VEdluK41GYqR3D/I625rFiOthHONpQD nExU9Iozs33I4PcEsxzy3c+Ee3B6a6gmVqQAkhATYn4AKeZBgW5zratfaC/ActZ2RScN UFWnvU+07Y9CfMnOAaklDKtKdFhZdjPS+MoxX2eZTmcze4neaWmPaQJGSCnJR5pvNLy6 i8PoMRCx775EGWFnrXu6oB2W/LyqqtZHgUyliayIczXf57HfnGdEcEwYYk60cAcjSKra 41Hw6aT4AupGJlpur+b0sTTUaOLg3D5A9uhlDRVxB+vpgg1DAkGz+s6TzOVFS2h7RiHI WiKQ== X-Forwarded-Encrypted: i=1; AJvYcCXrL7qINJhbzhI8OwirknHGT0D/iqTTXEIpMSJS3AxEg0MAJztrdz6NpNqpgjU6R9LoBQkNBsKbd5Ul/blhXCDyzyE= X-Gm-Message-State: AOJu0Ywj1DEJ6JHEazqEPx7uLvU3txg5f8QyGM7443vJYSEt6DW26ITo fWydlHGAj4FjNqDDpLGFl/nW7mmT/8q/lBd7wt51RFsMM8HyiNn2 X-Google-Smtp-Source: AGHT+IGFVtRgof2Vr7XnnRzUy5kTO/s4QSnWyIEEWJVSWOqsNKgzwT8cHzfUyKrMnHJALyfjycu/iQ== X-Received: by 2002:a05:6870:7006:b0:24f:e:b110 with SMTP id 586e51a60fabf-25121e3aed8mr2366720fac.35.1717578655520; Wed, 05 Jun 2024 02:10:55 -0700 (PDT) Received: from [192.168.255.10] ([43.132.141.20]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-70242b2e143sm8247886b3a.198.2024.06.05.02.10.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 05 Jun 2024 02:10:55 -0700 (PDT) Message-ID: Date: Wed, 5 Jun 2024 17:10:51 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 01/10] mm/ksm: reduce the flush action for ksm merging page To: David Hildenbrand , alexs@kernel.org, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, izik.eidus@ravellosystems.com, willy@infradead.org, aarcange@redhat.com, chrisw@sous-sol.org, hughd@google.com References: <20240604042454.2012091-1-alexs@kernel.org> <20240604042454.2012091-2-alexs@kernel.org> <9ca730ce-2b2f-42d2-8c7a-78735a995c64@redhat.com> <4d299245-3166-4810-b22b-2a5b4f54a049@gmail.com> <7c6ae2a3-8ec3-4c9b-81c3-125f6973f0f3@redhat.com> <59921e08-d0f1-4bc8-acee-368a978286a4@redhat.com> Content-Language: en-US From: Alex Shi In-Reply-To: <59921e08-d0f1-4bc8-acee-368a978286a4@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspam-User: X-Stat-Signature: ibofmudqrz5xdmbtmhx9nt6re83gf3mc X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 56DBE18000F X-HE-Tag: 1717578657-459448 X-HE-Meta: U2FsdGVkX186Htm26Od3ROf56jamNC8YIkkblq3bkHFjQi8dY3BjKkQ1cK9Podej6vmdkFmGUfWvqqdGvQYlAow5KVxjw9hMjY/TA4rJHL6//eGPCdlpxz0beuIwMjAlFVs0yMZUmV6lf3ruZo5bgEv+PFFuhO6OCoaqhGG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LZxCm2O3+XlYZ+39tFXyXt32CqXHCz/WEfbstypMAAKe0RSS5ZSZc6baYf9ljVteDzcfPh6XpqnwEZgKyR2i1Cq2LzKi7ROyZZgo4jL9qWVmewGI8AKzFGTWHumGDo02HR5vcDJnbcYZEpjfnkPd+LVUjZeG2BgJD1ieawtgR6K78HE4aAF31yeFGtNbgOc28BaTqHSRMVsqKDjSE67QTRWLaitAuDgPevrBBJeYk/njNWk7/DyTxEb0yGlB/EVmmEShsL2sTV9OganW+vqA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000005, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 6/5/24 3:26 PM, David Hildenbrand wrote: > On 04.06.24 15:02, Alex Shi wrote: >> >> >> On 6/4/24 6:45 PM, David Hildenbrand wrote: >>> On 04.06.24 12:26, Alex Shi wrote: >>>> >>>> >>>> On 6/4/24 4:07 PM, David Hildenbrand wrote: >>>>> On 04.06.24 06:24, alexs@kernel.org wrote: >>>>>> From: "Alex Shi (tencent)" >>>>>> >>>>>> We can put off the flush action util a merging is realy coming. That >>>>>> could reduce some unmerge page flushing. >>>>>> BTW, flushing only do at arm, mips and few other archs. >>>>>> >>>>> >>>>> I'm no expert on that flushing, but I thought we would have to do the flushing before accessing page content -- before calculating the checksum etc. >>>>> >>>>> Now you would only do it before the pages_identical() check, but not when calculating the checksum. >>>>> >>>> >>>> Hi David, >>>> >>>> Thanks a lot for comments! >>>> >>>> If calc_checksum() is wrong before pages_idential(), (that's just after page was write_protected, that's a real guarantee for page context secured) pages_identical could recheck and make thing right. >>>> >>> >>> Yes, but you would get more wrong checksums, resulting in more unnecessary pages_identical() checks. >>> >>> That is missing from the description, and why we want to change that behavior. >>> >>> What's the net win? >>> >>>> And as to 2 flush functions here, I didn't see the guarantee for other writer from any other place. So maybe we should remove these flush action? >>> >>> "I didn't see the guarantee for other writer from any other place" can you rephrase your comment? >>> >>> If you mean "the process could modify that page concurrently", then you are right. But that's different than "the process modified the page in the past and we are reading stale content because we missed a flush". >> >> >> Maybe moving the flush before checksum could relief some worries. :) >> But still no one knows what flush really help, since if page content only syncs to memory by the flush, the kernel or process can't be work with current code. > > Please explain to me why we care about moving the flushs at all :) > > If they are NOP on most architectures either way, why not simply leave them there and call it a day? Uh, 2 reasons: 1, it uses page and can't convert to folio now. 2, as you pointed, flush action w/o page reading seems just waste time. Thanks Alex >