Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp2579754rwb; Sun, 6 Aug 2023 23:01:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh8i1CH/erfTDtsxCTTEcjiPvRVDAqIpmQdVKCCRRQUPWbIz28CbjruvUcV1r9EHRtzpAH X-Received: by 2002:a17:907:7857:b0:99c:7551:933e with SMTP id lb23-20020a170907785700b0099c7551933emr7426590ejc.64.1691388078024; Sun, 06 Aug 2023 23:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691388078; cv=none; d=google.com; s=arc-20160816; b=b4RTju9tfxNUcz6fX698S/vsAPEowttjS6Fz48ti7b50K8k8FavNy/as5hUws6nn1a R50wI8X5Dr8Ik+u3W4UiibDO9xtkCLbdUUpaALNTT0IwFzrLiis6FVq52Mq+AbvhGws0 5L0KryDqmA6n1GmUphmI2t0DUgUMi/jYsI40ytuWj/GhV3kYPfnE/CON604MqP6aDdoH U96dsZdTzBoFlkVHbB4Jc06XOHibrHJolFjERl/Eq6QTMQAjvrYxc0nPBG/Huoby6jUg VM2GqeX9FqAMIOd7ovdhKS7HsSvrkGhoRjZ3SYG6wEC/4cFzanD4l+/ynfVrkoS8Buqk +N5Q== 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=E+2EbnFZV7yJtZskjh+cWG4NxmXWzvfmJSRPX0ne/hU=; fh=G0w13uVvSb0UTPtwFMWlQut9UI02fgm5FkliwnRi5wY=; b=MrM4mJjt9lZLsx+yLn2ZXYXelBHN+mfymmLlY2AgnuIKE0dPw5w3SKaw5fx3a3MVhP aPnhcVG+uxlg071TlpLs4KH2lLi78n+dfIWLB8Xsz7HQixk0uZM6+c5ncg58BMB3cQyY pIXJ21w7dzTA73dI8o8cRW5MMgexyWMvjd00Osqt54B4Nli5MtB+0QHr2e2ypYPVUVyv 2MD+2eZOLf4wogRovFS+pX8Pd/DYZkHCtfqIKl4FSKhVOHe1jzHH89xFAJgHe4neUOKD jgLNl/x0a6LSCWG/nlKMSoDmBRMARXMcZP6LyWrVlU32Rud+qboqp760c12cBhGpvGIj Lb9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Gok80n6k; 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 z27-20020a170906715b00b0099bcde0f1b1si4522447ejj.152.2023.08.06.23.00.52; Sun, 06 Aug 2023 23:01:18 -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=Gok80n6k; 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 S229513AbjHGEoz (ORCPT + 99 others); Mon, 7 Aug 2023 00:44:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229747AbjHGEox (ORCPT ); Mon, 7 Aug 2023 00:44:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A2B610FE for ; Sun, 6 Aug 2023 21:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691383450; 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=E+2EbnFZV7yJtZskjh+cWG4NxmXWzvfmJSRPX0ne/hU=; b=Gok80n6k1JA4onMrnAOha7hVQmzE3KGkcH1CF9kCML69KMTZHbOMvtogNX9wN952GTSls2 oGCWho1F2/eKtmUMuyBK9SiRTdAXXZBCgCmzaN8vCFrAXCyawxfqtTKJf53Xyc9brZ1nu2 wmoBdb6/15s6F4QzEn45WXClSyS7CMg= Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-28-PZmsn8s2NV-ZPAaCJvNfVA-1; Mon, 07 Aug 2023 00:44:08 -0400 X-MC-Unique: PZmsn8s2NV-ZPAaCJvNfVA-1 Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-68701df1ac7so2597577b3a.1 for ; Sun, 06 Aug 2023 21:44:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691383447; x=1691988247; 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=E+2EbnFZV7yJtZskjh+cWG4NxmXWzvfmJSRPX0ne/hU=; b=OxOfM/HD8gOUF6inKj0sMSb6XBgeauRE/mFn2CVJGSN3hnmPDdOYO+echmEduq0QoT VEWyz2RP2TsiAwCuNvS8WkALm2FEPeQ8sUONtZmChz6orqmJn1hurudGHGBD9eta+ejx LN3HPETrvbd+xfEjUdQDkoiuqaGps3KOytspBN9GQu0CpRIC+La6dCU4AAypKgBGKWSD u/iuzgXJ4eXjoTfSLpwhHzbtOsnXGzNuIzo43BPFtrZFIsY25Qbl5hV9x5RVCtzw/Fx3 tXQ3f/u5/qmPswgf2Qe/E+mMEJ4h/EpYkz7DiAXpbSi0XbOV1ycT+eFFDpYJzL3RdqXL riTQ== X-Gm-Message-State: AOJu0Yy180/QR3B0uiyL75NVQpXjiL72824uYNakiYABAN/sMRk5J+Vn puksSn2QEGDlqdbBe+BQyVlfc3af+ANzUUVDnHAXrfCoqCtBAUWOU2VEjQ+WGCRRB4OqnM7HMKg qZzsslWt3jdU5JonvUS+Imjsr X-Received: by 2002:a05:6a20:1006:b0:125:f3d8:e65b with SMTP id gs6-20020a056a20100600b00125f3d8e65bmr7292036pzc.18.1691383447541; Sun, 06 Aug 2023 21:44:07 -0700 (PDT) X-Received: by 2002:a05:6a20:1006:b0:125:f3d8:e65b with SMTP id gs6-20020a056a20100600b00125f3d8e65bmr7292025pzc.18.1691383447235; Sun, 06 Aug 2023 21:44:07 -0700 (PDT) Received: from fedora19.localdomain ([2401:d002:2d05:b10a:c9ac:2dd7:6463:bb84]) by smtp.gmail.com with ESMTPSA id iz7-20020a170902ef8700b001b895a17429sm5697860plb.280.2023.08.06.21.44.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Aug 2023 21:44:06 -0700 (PDT) Date: Mon, 7 Aug 2023 14:44:00 +1000 From: Ian Wienand To: Minchan Kim Cc: Petr Vorel , ltp@lists.linux.it, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Nitin Gupta , Sergey Senozhatsky , Jens Axboe , OGAWA Hirofumi , Martin Doucha , Yang Xu Subject: Re: [PATCH 0/1] Possible bug in zram on ppc64le on vfat Message-ID: References: <20221107191136.18048-1-pvorel@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,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 After thinking it through, I think I might have a explanation... On Fri, Aug 04, 2023 at 04:37:11PM +1000, Ian Wienand wrote: > To recap; this test [1] creates a zram device, makes a filesystem on > it, and fills it with sequential 1k writes from /dev/zero via dd. The > problem is that it sees the mem_used_total for the zram device as zero > in the sysfs stats after the writes; this causes a divide by zero > error in the script calculation. > > An annoted extract: > > zram01 3 TINFO: /sys/block/zram1/disksize = '26214400' > zram01 3 TPASS: test succeeded > zram01 4 TINFO: set memory limit to zram device(s) > zram01 4 TINFO: /sys/block/zram1/mem_limit = '25M' > zram01 4 TPASS: test succeeded > zram01 5 TINFO: make vfat filesystem on /dev/zram1 > > >> at this point a cat of /sys/block/zram1/mm_stat shows > >> 65536 527 65536 26214400 65536 0 0 0 > > zram01 5 TPASS: zram_makefs succeeded So I think the thing to note is that mem_used_total is the current number of pages (reported * PAGE_SIZE) used by the zsmalloc allocator to store compressed data. So we have made the file system, which is now quiescent and just has basic vfat data; this is compressed and stored and there's one page allocated for this (arm64, 64k pages). > zram01 6 TINFO: mount /dev/zram1 > zram01 6 TPASS: mount of zram device(s) succeeded > zram01 7 TINFO: filling zram1 (it can take long time) > zram01 7 TPASS: zram1 was filled with '25568' KB > > >> however, /sys/block/zram1/mm_stat shows > >> 9502720 0 0 26214400 196608 145 0 0 > >> the script reads this zero value and tries to calculate the > >> compression ratio > > ./zram01.sh: line 145: 100 * 1024 * 25568 / 0: division by 0 (error token is "0") At this point, because this test fills from /dev/zero, the zsmalloc pool doesn't actually have anything in it. The filesystem metadata is in-use from the writes, and is not written out as compressed data. The zram page de-duplication has kicked in, and instead of handles to zsmalloc areas for data we just have "this is a page of zeros" recorded. So this is correctly reflecting that fact that we don't actually have anything compressed stored at this time. > >> If we do a "sync" then redisply the mm_stat after, we get > >> 26214400 2842 65536 26214400 196608 399 0 0 Now we've finished writing all our zeros and have synced, we would have finished updating vfat allocations, etc. So this gets compressed and written, and we're back to have some small FS metadata compressed in our 1 page of zsmalloc allocations. I think what is probably "special" about this reproducer system is that it is slow enough to allow the zero allocation to persist between the end of the test writes and examining the stats. I'd be happy for any thoughts on the likelyhood of this! If we think this is right; then the point of the end of this test [1] is ensure a high reported compression ratio on the device, presumably to ensure the compression is working. Filling it with urandom would be unreliable in this regard. I think what we want to do is something highly compressable like alternate lengths of 0x00 and 0xFF. This will avoid the same-page detection and ensure we actually have compressed data, and we can continue to assert on the high compression ratio reliably. I'm happy to propose this if we generally agree. Thanks, -i > [1] https://github.com/linux-test-project/ltp/blob/8c201e55f684965df2ae5a13ff439b28278dec0d/testcases/kernel/device-drivers/zram/zram01.sh