From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 83B4E2FE059 for ; Mon, 29 Sep 2025 10:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759143414; cv=none; b=MNugIKq48ONh4MjV6hLyUmsB1scsAGjRJqvvcbLsrGhFMl5iiYDFS3WmthL6QbnXfl3ras6EA8cytPeMZDeXeD/X/akblQfSYcwMbLfVVxVLTFQRSQRJq0stS2wOI5f5fAhImt700fDXluGSpnLD+mxbfuGSxhK7NQD+XFPn15U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759143414; c=relaxed/simple; bh=Dke5jhzsmCxDfN+1PMDq1SfW1G4fUtvUQCDvbzw0SzU=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=imHODhrmsvrv//QO2vJyN1QSY6H2hhQM2w7/8yTGwsXkKoCewiJMwRf4NLKfJFFKIYzu2P+MsALOm6qOykDnOrzWMLMlGz6ZMn0EMd66suoa9glE4+AsdiFB0stVWKvyTw+3ehviWOSEhTKAc6b/t1x3/jGtaoEA7YjLdNmRoGM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Et05Pa/X; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Et05Pa/X" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-32eaeba9abaso6752138a91.3 for ; Mon, 29 Sep 2025 03:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1759143412; x=1759748212; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=jnlF0eFQWr0BxLvIHq4uqg9GVwgOdVNiok3YvVZbq0c=; b=Et05Pa/XyOm8/6EFW8JWsJsgPjHG8izacmTd59GETQLnaoyCvFDn6hF/Uj1Ry8p3y6 nj7k/qR/+nGpqJG5Ii48O4hI2h+uafd4p1q+Erk3q7t7+uPhE+sdBhC/SqoUFZVgDqml bmnEOzvvB5clxTSNdkb91zY/dru/sI6ZmjJj/XhH5CczypyLvenPSKqrH7ftKrPYf1S+ koHU30LXRbM1oSYudki4Yq/GaC3tU5ueLikV8nYJf6VrUnzNSpA4gfrlLid4ffHbPk9D fosxFiGxgU5KwWvbWrQxd/1Vcf0NtEVED0ae5qM9qVm8fnBj7DLqolapz5Z8Lp/gKvxm vCsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759143412; x=1759748212; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=jnlF0eFQWr0BxLvIHq4uqg9GVwgOdVNiok3YvVZbq0c=; b=wr/IYufldeUxymbMpz1NKPNmxT3gbh1jrqFct5+EYXi3WqgxPWbxT/TwR9RdyFMZ68 foRKaSjQje3UHUaOfWem1pbmwq0yv+VAL6YrBgSJs62QJ2rZFG0Lx9ikuKEIssxc20af Fk5cURu4FPud6/c5fI4e1Y9c4m3uJRPLRh65oTFoaS+/E9BjLb4GtVqsASepG/jPMi8d SjmeZKhNFOY03rQ/2KlWFok7HWjhG7u/Ojl/62BQDk2zzTSdAJIK3GQFAqbOX2AQGKyx +NMCRvTTotZAmFhF/LeCk3+FRw98sLLyzQhTv2G5Xeth5QZ57nC5nYlYk3I1LgVupevc wIpw== X-Forwarded-Encrypted: i=1; AJvYcCVqlEOzVP+tF39AqT8bOSJT98hOBbFwLOrL7vQLcNIUfU3ig8RcoFD1aaQxS2waSdjeamKXokJRSNZ0UCg=@vger.kernel.org X-Gm-Message-State: AOJu0YyBcfcjUd+kD4DHfqGZaLFyVkG8x1nQJEOK46yK56P3DzojWIlC Bm096tvczVUHLZE9I+w4FWH5oRCyrQWX0e4lOp7tGGzCxen4hvubFFzWLjBrNPplFiA8EjHz57+ fEq0iMQl3grsioFAyZAfqpD+bwQ== X-Google-Smtp-Source: AGHT+IGVa3dr0UfHdFFHv7a2nhejmco2UUe8ClD2YEi2nAiUc0fVQ4XataHCX+47Wk38A2rAeoA+fcK1m/NCoi2faA== X-Received: from pjok1.prod.google.com ([2002:a17:90a:9101:b0:330:55ed:d836]) (user=ackerleytng job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:1d87:b0:329:f535:6e48 with SMTP id 98e67ed59e1d1-3342a30be1amr15992420a91.36.1759143411908; Mon, 29 Sep 2025 03:56:51 -0700 (PDT) Date: Mon, 29 Sep 2025 10:56:50 +0000 In-Reply-To: <20250926163114.2626257-3-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250926163114.2626257-1-seanjc@google.com> <20250926163114.2626257-3-seanjc@google.com> Message-ID: Subject: Re: [PATCH 2/6] KVM: selftests: Stash the host page size in a global in the guest_memfd test From: Ackerley Tng To: Sean Christopherson , Paolo Bonzini , Christian Borntraeger , Janosch Frank , Claudio Imbrenda Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Hildenbrand , Fuad Tabba , Sean Christopherson Content-Type: text/plain; charset="UTF-8" Sean Christopherson writes: > Use a global variable to track the host page size in the guest_memfd test > so that the information doesn't need to be constantly passed around. The > state is purely a reflection of the underlying system, i.e. can't be set > by the test and is constant for a given invocation of the test, and thus > explicitly passing the host page size to individual testcases adds no > value, e.g. doesn't allow testing different combinations. > I was going to pass in page_size to each of these test cases to test HugeTLB support, that's how page_size crept into the parameters of these functions. Could we do a getpagesize() within the gmem_test() macro that you introduced instead? Reviewed-by: Ackerley Tng > Making page_size a global will simplify an upcoming change to create a new > guest_memfd instance per testcase. > > No functional change intended. > > Signed-off-by: Sean Christopherson > --- > .../testing/selftests/kvm/guest_memfd_test.c | 37 +++++++++---------- > 1 file changed, 18 insertions(+), 19 deletions(-) > > diff --git a/tools/testing/selftests/kvm/guest_memfd_test.c b/tools/testing/selftests/kvm/guest_memfd_test.c > index 81b11a958c7a..8251d019206a 100644 > --- a/tools/testing/selftests/kvm/guest_memfd_test.c > +++ b/tools/testing/selftests/kvm/guest_memfd_test.c > @@ -24,6 +24,8 @@ > #include "test_util.h" > #include "ucall_common.h" > > +static size_t page_size; > + > static void test_file_read_write(int fd) > { > char buf[64]; > @@ -38,7 +40,7 @@ static void test_file_read_write(int fd) > "pwrite on a guest_mem fd should fail"); > } > > -static void test_mmap_supported(int fd, size_t page_size, size_t total_size) > +static void test_mmap_supported(int fd, size_t total_size) > { > const char val = 0xaa; > char *mem; > @@ -78,7 +80,7 @@ void fault_sigbus_handler(int signum) > siglongjmp(jmpbuf, 1); > } > > > [...snip...] >