Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40D07130E48 for ; Tue, 27 Feb 2024 09:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025154; cv=none; b=qlfRdQxZtK3FEhSE8MT4eom94FQoPqPIGUF5tNk+KjZpODLW5Vyfa+EeKd1JA5XWubEqOmj343OkEMeUM/iqfQbvyk5w691vloOS0DggiRULNLM/Rq4aYJ4Wd7l3FDg/oa/lBP8GbjzXtUuZUBpgfLEp4xbpVzE4vK3PPMW18vY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709025154; c=relaxed/simple; bh=Zf/ONOLrZyforMFmdbgWSo9YHz8Lv21YnYvGjjwCP0w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=eE1kkweaJBqgRjqUEMe3HHqeAN/pQMcwGujOrIL0K2TgOZx7NCkynZt4nO1B2BaUjDoqDbBK/10oHpLGFLM2x4klBvQxOVuG/gPbeK59qrNuIRIERTIj2lxa8hdB+Wo/c8I2eqJQLIFbpNrhOk06lNQdM1RzvwKydV6oKqax2m0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PNYe5P0R; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PNYe5P0R" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709025151; h=from:from:reply-to: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=v+RdFPWoEi4G0dpITK5HWGkYzQ6cUrxSrSkxlO/IF04=; b=PNYe5P0RoYdrjNqIefUh5aRr0tRQdJkfg8hqCULk8AKEjbqaGMWDXU5ceIy7AvK8lVSeOl Y4GOZ36HcaKMk+IXi6h/yuhi5H1UzWXMYbDfqkSuU2noQIiLy7v9pfPZo7TURzXbjmLw6O pEA8KXHIU33rbYGJe+981Esr/7Yv3DA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-627-TdEwwMHjOVWUMPyxAOmaHA-1; Tue, 27 Feb 2024 04:12:28 -0500 X-MC-Unique: TdEwwMHjOVWUMPyxAOmaHA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 567DA106D1AC; Tue, 27 Feb 2024 09:12:27 +0000 (UTC) Received: from redhat.com (unknown [10.42.28.56]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0941BC185C0; Tue, 27 Feb 2024 09:12:22 +0000 (UTC) Date: Tue, 27 Feb 2024 09:12:20 +0000 From: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= To: Zhao Liu Cc: Jonathan Cameron , Eduardo Habkost , Marcel Apfelbaum , Philippe =?utf-8?B?TWF0aGlldS1EYXVk77+9?= , Yanan Wang , "Michael S . Tsirkin" , Paolo Bonzini , Richard Henderson , Eric Blake , Markus Armbruster , Marcelo Tosatti , Alex =?utf-8?B?QmVubu+/vWU=?= , Peter Maydell , Sia Jee Heng , qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-riscv@nongnu.org, qemu-arm@nongnu.org, Zhenyu Wang , Dapeng Mi , Yongwei Ma , Zhao Liu Subject: Re: [RFC 4/8] hw/core: Add cache topology options in -smp Message-ID: Reply-To: Daniel =?utf-8?B?UC4gQmVycmFuZ8Op?= References: <20240220092504.726064-1-zhao1.liu@linux.intel.com> <20240220092504.726064-5-zhao1.liu@linux.intel.com> <20240226153947.00006fd6@Huawei.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 On Tue, Feb 27, 2024 at 05:20:25PM +0800, Zhao Liu wrote: > Hi Jonathan, > > > Hi Zhao Liu > > > > I like the scheme. Strikes a good balance between complexity of description > > and systems that actually exist. Sure there are systems with more cache > > levels etc but they are rare and support can be easily added later > > if people want to model them. > > Thanks for your support! > > [snip] > > > > +static int smp_cache_string_to_topology(MachineState *ms, > > > > Not a good name for a function that does rather more than that. > > What about "smp_cache_get_valid_topology()"? > > > > > > + char *topo_str, > > > + CPUTopoLevel *topo, > > > + Error **errp) > > > +{ > > > + *topo = string_to_cpu_topo(topo_str); > > > + > > > + if (*topo == CPU_TOPO_LEVEL_MAX || *topo == CPU_TOPO_LEVEL_INVALID) { > > > + error_setg(errp, "Invalid cache topology level: %s. The cache " > > > + "topology should match the CPU topology level", topo_str); > > > + return -1; > > > + } > > > + > > > + if (!machine_check_topo_support(ms, *topo)) { > > > + error_setg(errp, "Invalid cache topology level: %s. The topology " > > > + "level is not supported by this machine", topo_str); > > > + return -1; > > > + } > > > + > > > + return 0; > > > +} > > > + > > > +static void machine_parse_smp_cache_config(MachineState *ms, > > > + const SMPConfiguration *config, > > > + Error **errp) > > > +{ > > > + MachineClass *mc = MACHINE_GET_CLASS(ms); > > > + > > > + if (config->l1d_cache) { > > > + if (!mc->smp_props.l1_separated_cache_supported) { > > > + error_setg(errp, "L1 D-cache topology not " > > > + "supported by this machine"); > > > + return; > > > + } > > > + > > > + if (smp_cache_string_to_topology(ms, config->l1d_cache, > > > + &ms->smp_cache.l1d, errp)) { > > > > Indent is to wrong opening bracket. > > Same for other cases. > > Could you please educate me about the correct style here? > I'm unsure if it should be indented by 4 spaces. It needs to look like this: if (smp_cache_string_to_topology(ms, config->l1d_cache, &ms->smp_cache.l1d, errp)) { so func parameters are aligned to the function calls' opening bracket, not the 'if' statement's opening bracket. With regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|