Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp1898662lqo; Mon, 13 May 2024 01:30:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXYPZHwmtm9loE1DwGMVx0z4GXE7xcAo8//TIVm9xgVXEzYeEoCT3e+PJGHGbD20mmibhCP/f5gfyVBNPtIQAoC/GgIsQndBOE8Tt/fzA== X-Google-Smtp-Source: AGHT+IEqmzk0pO1qwcq0ModUFLaUMiiVI3oc+E0bHxUyqtcCcQcaX0Rrec/ouYryqV4/IisXmJrp X-Received: by 2002:a05:6359:4115:b0:192:2540:554c with SMTP id e5c5f4694b2df-193baee5b03mr966864655d.1.1715589022996; Mon, 13 May 2024 01:30:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715589022; cv=pass; d=google.com; s=arc-20160816; b=dCtltPYsuq829RK80Xq/olRQyEqjHq7JIQ66uUrMVZfA45H6C9cr9oh0dUuNnNQTlA rUGyXxpJtARBjJRo79b0gViMOuNEBRVbwT5WYRArRh5eadGc+5LPSPlbJupLsXaQ7OCs gRutOuJ9T9OtplX+5XvAZt50Gc7Yepmr7uZbEOWmI4PUWv3yabw7C0vowW0chJadXiSo 5uLJkYWgKMl/zEedsYihwEMGzwaAPsI1R0VrxnqH1DWfqsDk0YdDQ8Vnuw+hitMnkspw dOQoJGmPvypDp8gKBRioxHOZzAOOpYrboQtFy0x3N2QgM0DXmDaCt7ff+L0lrFEk5GwD qtiQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=K5weZYDlM9HYwC/58QwF7EZSftYlvZYQrfkF/WhlHWk=; fh=sjxBMbigrgKUzplA8V3gIjRPqs2fwVVyor1W+PgO1Zk=; b=ic0zBSNay8fM2357/3K3IhHrNmEuTcII1sf/j12lw6hwXV+LjNE+pSTIEs5YvqFeX+ 5XQ35/DuzkQNSBAc/pREVDCToEHWtFly6Dghtjvd5xcwcFRmobUNl2WawY9QHkIDskO4 /wfYhkD6Y+RaN2qKMT3w4ElGREsE26u3tsMw4Ig/da0oE5NXFxw19Hf6+YTUxiimcDZs iBobyKUWUpEHwXYp+YCZ5umimsM4wEDYsGp1zrohQxH1XGC1WN99mc39seNIfQ/ND9Ol eBTLxTXozVIK6O9vZovVCiVS+8KkXHOnf42OfyV0gdjqqdQRUUOpp6jdDff9BH5MziG3 GbCA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-177347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f6e49si8627711a12.359.2024.05.13.01.30.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 May 2024 01:30:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-177347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-177347-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-177347-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id F2036281ECC for ; Mon, 13 May 2024 08:29:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 872291474C4; Mon, 13 May 2024 08:29:48 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8DBBE1474B8; Mon, 13 May 2024 08:29:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715588988; cv=none; b=QMjF0c3jD18Ghw2fRVo7wDVWAqJRyMYDQcssaezzdLVT0p2eecy100OtGGywcWC7ON0ydhFOXwljSGhtUoqpaK3t5UAkuUyW26PR3T9+R12tNBbqDtBro3F3NDGMjDKYOiEMLuoRfNqpJZYM3a6X5EU/RgulPb8BtjGupLuD758= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715588988; c=relaxed/simple; bh=w2OxaGvxyHVfOAWRircL4Fn/3IZtA341il1A/uniA30=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=P9bvBP2kb0rTpRZgm5veDMi5hVi2rUIzmB+oIAKx3svbR3tbEFVXu/fUYmKgdBbobkEJueSDaFxE41czbr/ZqYN2Qt8jHV2fBsFknUOHmMl48V4pqEnVdplsH6phcr0NhTgO7ch1sgiXTdx77NCTmIXyH9HfMPE8XVuzwPaYswE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id F19F21007; Mon, 13 May 2024 01:30:09 -0700 (PDT) Received: from e116581.blr.arm.com (e116581.arm.com [10.162.42.12]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 4A3493F7A6; Mon, 13 May 2024 01:29:42 -0700 (PDT) From: Dev Jain To: akpm@linux-foundation.org, shuah@kernel.org Cc: linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Anshuman.Khandual@arm.com, Dev Jain Subject: [PATCH] selftests/mm: compaction_test: Fix trivial test pass on Aarch64 when nr_hugepages = 0 Date: Mon, 13 May 2024 13:58:42 +0530 Message-Id: <20240513082842.4117782-1-dev.jain@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Currently, if at runtime we are not able to allocate a huge page, the test will trivially pass on Aarch64 due to no exception being raised on division by zero while computing compaction_index. Fix that by checking for nr_hugepages == 0. Anyways, in general, avoid a division by zero by exiting the program beforehand. While at it, fix a typo. Signed-off-by: Dev Jain --- tools/testing/selftests/mm/compaction_test.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/mm/compaction_test.c b/tools/testing/selftests/mm/compaction_test.c index 533999b6c284..df1b76f9c734 100644 --- a/tools/testing/selftests/mm/compaction_test.c +++ b/tools/testing/selftests/mm/compaction_test.c @@ -134,6 +134,10 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size) /* We should have been able to request at least 1/3 rd of the memory in huge pages */ + if (!atoi(nr_hugepages)) { + ksft_print_msg("ERROR: No memory is available as huge pages\n"); + goto close_fd; + } compaction_index = mem_free/(atoi(nr_hugepages) * hugepage_size); lseek(fd, 0, SEEK_SET); @@ -149,7 +153,7 @@ int check_compaction(unsigned long mem_free, unsigned int hugepage_size) atoi(nr_hugepages)); if (compaction_index > 3) { - ksft_print_msg("ERROR: Less that 1/%d of memory is available\n" + ksft_print_msg("ERROR: Less than 1/%d of memory is available\n" "as huge pages\n", compaction_index); goto close_fd; } -- 2.39.2