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 A9D07C4332F for ; Wed, 16 Nov 2022 16:25:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED0B88E0001; Wed, 16 Nov 2022 11:25:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E81426B0073; Wed, 16 Nov 2022 11:25:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D48428E0001; Wed, 16 Nov 2022 11:25:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C5DC36B0071 for ; Wed, 16 Nov 2022 11:25:42 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6AAE01202EB for ; Wed, 16 Nov 2022 16:25:42 +0000 (UTC) X-FDA: 80139831324.24.B25B4AB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf05.hostedemail.com (Postfix) with ESMTP id A0F03100010 for ; Wed, 16 Nov 2022 16:25:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668615940; 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: in-reply-to:in-reply-to:references:references; bh=tZZG5773YY8mLmTXTvUfSvM9dtomJZB7uijJ4GU3KOw=; b=hLr/SJgM9vfGyvl8rtU8efbS6zSG1WF6Dly8Aa1SVJ51UwDkOIEbmA81GD+D03Sw7ott0q yHwFGmm6KTBlaS0UXdDO1/fB/0ZA41z869gjr6wXUWQTNPt+hDsVCTtzzxch3fTFwCGaTO 7CP5tinJdXxM6AirWh5ltE0amN7RmNo= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-557-MAfp5h74OhWalZn5ABYwLA-1; Wed, 16 Nov 2022 11:25:38 -0500 X-MC-Unique: MAfp5h74OhWalZn5ABYwLA-1 Received: by mail-qk1-f200.google.com with SMTP id h13-20020a05620a244d00b006fb713618b8so9576122qkn.0 for ; Wed, 16 Nov 2022 08:25:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=tZZG5773YY8mLmTXTvUfSvM9dtomJZB7uijJ4GU3KOw=; b=sN0USpFXS/Xw9uZPCZdWjX7cNN23E1PLj1XRFoMMhoG1L3eVKEGzQMQDG+EZUJiFPE /pKtRG5eSRlSHi6Kegg5varHKekxYzwacTcoMgmghyzav0tZeqbzZkxcna+Opsbiuo8+ Pa5uM4Dh+EViJ49EVtnsG4bnxi3D8dZzCdIyfLMu8DQ997MZpQM628gb4CWu8r15aegx htrrO5RYWNq/6vozTmXP2h1JZTRzuF+vWHMEQ8EuDa/vzqjf4fqdsmIm6qY9QgbScsiH rduenwgE60LAwPDvRcOu59Zf9EFx232g6qQevoZfzRb3gmHUGZ8gDzrGdFjm3EwrzQIv DS4g== X-Gm-Message-State: ANoB5pnJmqB94LgfEZgaKnJUFyVGWDoJJD2odX2YqbfEC0Y6c1wj4pSt zTxuV+OhLwO/WViBxv9u74VwhwTvAzkY/rCWDR7/+YQgn/zEeyPFy/Y3kW2zCSJo4sptgIfNUpV 75Obdt7CqbTo= X-Received: by 2002:ac8:7a81:0:b0:3a5:6131:6438 with SMTP id x1-20020ac87a81000000b003a561316438mr21956459qtr.164.1668615937927; Wed, 16 Nov 2022 08:25:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7695HWXTep81cSyE1V03duopul61bFYUW3N8qUeviRu+gTCSrQMXJmzY9BDWU29BQ+ziD58Q== X-Received: by 2002:ac8:7a81:0:b0:3a5:6131:6438 with SMTP id x1-20020ac87a81000000b003a561316438mr21956446qtr.164.1668615937677; Wed, 16 Nov 2022 08:25:37 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-46-70-31-27-79.dsl.bell.ca. [70.31.27.79]) by smtp.gmail.com with ESMTPSA id s8-20020a05620a254800b006ee8874f5fasm10163228qko.53.2022.11.16.08.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 08:25:37 -0800 (PST) Date: Wed, 16 Nov 2022 11:25:36 -0500 From: Peter Xu To: Anatoly Pugachev , hev Cc: hev , Thorsten Leemhuis , Sparc kernel list , linux-mm Subject: Re: Test case for "mm/thp: carry over dirty bit when thp splits on pmd" Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668615940; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tZZG5773YY8mLmTXTvUfSvM9dtomJZB7uijJ4GU3KOw=; b=wLvPhOIztBtai65zzqnVKb6sMeXLSkPz7lHJOfTc6JJ7ieUgaFSuJb8Gt9xUN6MFUpaDMi zgfJN9CF79Hz4MOZoPUfiebzcgFdliN4VzZDMudUaRprPo+mvPIrZJlIHv985Re3Z75a5f GUrsm2Q6ccTjEnKs/UBAL2WRVhxSb6w= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hLr/SJgM"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668615940; a=rsa-sha256; cv=none; b=jaUZu281qUik+8Lm096jR2JEn6B+hFfTcTsFwSzsjZUB/2LgLUOoS6B4faf83kEb4oHABz 2f8/p6pg9iA2JeoVqrLMDwJFvmdmtXKr4VQBCCG5UiL2Anp+nbQohdLFwqHdhdvEwdhlPR XQiLdkigs2LMyrjv5OfI5CDVVjGTJbQ= X-Rspam-User: X-Stat-Signature: 17u1r4dkotidqmzzt5d9ddac6re7y9h3 X-Rspamd-Queue-Id: A0F03100010 Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hLr/SJgM"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com X-Rspamd-Server: rspam07 X-HE-Tag: 1668615940-966362 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Nov 16, 2022 at 01:45:15PM +0300, Anatoly Pugachev wrote: > On Wed, Nov 16, 2022 at 11:49 AM hev wrote: > > > > Hello Peter, Hi, Hev, Thanks for letting me know. > > > > I see a random crash issue on the LoongArch system, that is caused by > > commit 0ccf7f1 ("mm/thp: carry over dirty bit when thp splits on > > pmd"). > > > > Now, the thing is already resolved. The root cause is arch's mkdirty > > is set hardware writable bit in unconditional. That breaks > > write-protect and then breaks COW. Could you help explain how that happened? I'm taking example of loongarch here: static inline pte_t pte_mkdirty(pte_t pte) { pte_val(pte) |= (_PAGE_DIRTY | _PAGE_MODIFIED); return pte; } #define _PAGE_MODIFIED (_ULCAST_(1) << _PAGE_MODIFIED_SHIFT) #define _PAGE_MODIFIED_SHIFT 9 #define _PAGE_DIRTY (_ULCAST_(1) << _PAGE_DIRTY_SHIFT) #define _PAGE_DIRTY_SHIFT 1 I don't see when write bit is set, which is bit 8 instead: #define _PAGE_WRITE (_ULCAST_(1) << _PAGE_WRITE_SHIFT) #define _PAGE_WRITE_SHIFT 8 According to loongarch spec: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html#section-multi-level-page-table-structure-supported-by-page-walking Bits 1 & 8 match the spec D & W definitions. Bit 9 seems not defined but I didn't quickly spot how that's related to the write bit. > > > > Here is a simple and fast testcase (It may be helpful for sparc64): > > https://gist.github.com/heiher/72919fae6b53f04cac606a9631100506 > > (assertion: c sum == 0) > > Just tried on my sparc64 VM - fixed vs old (non-patched) kernels... > > fixed kernel (6.1.0-rc5) running ./a.out: > mator@ttip:~$ ./a.out > c sum: 0 > p sum: 35184372088832 > c sum: 0 > p sum: 35184372088832 > c sum: 0 > p sum: 35184372088832 > c sum: 0 > p sum: 35184372088832 > c sum: 0 > p sum: 35184372088832 > ... > > old (non-patched) kernel (6.1.0-rc4) : > mator@ttip:~$ ./a.out > c sum: 35150012350464 > p sum: 35184372088832 > c sum: 35150012350464 > p sum: 35184372088832 > ... Thanks for the quick run, Anatoly. Obviously I went the wrong way before on the code patching. It seems we have more chance fixing this. -- Peter Xu