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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 304E6C3DA59 for ; Sat, 20 Jul 2024 00:00:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C60B310E217; Sat, 20 Jul 2024 00:00:12 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Ylg76yH6"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9516C10E217; Sat, 20 Jul 2024 00:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1721433611; x=1752969611; h=date:message-id:from:to:cc:subject:in-reply-to: references:mime-version; bh=aBoz3VQtKjR347qbQvuPrbIrMs7EZ4ScxRPSRxtCVRg=; b=Ylg76yH610hIrCkf+nkaVe6/qRtbFEvHhajcYw5SEF9Qhxdj2aaJwboo KIq+80D+OVkUfZcYJ1qrw4D8Z7u/Vy5tPfcUVYeA67st1FnpHOj9vQ4nZ mJlRXDthsNZyROlu6si8TS7CvT2aMmS8dpSUHp0y1pcKFHmX8DdLi+pFj dGqkaE8jmfwudyPE8DxE9PU/9VeHuWI/S/+9XrbX90tuIlQ/HjZFwFjh+ aY6odzxnc5AakeKlB3RFKxKS3YhTC2vaJiZoVewuynDd+1K0djb7C/9gG mHlMCIg9InrP4QnWi75pF2RCO0VP6sWGlmSvA9vLNBeIx8qjgtNeMpUwg A==; X-CSE-ConnectionGUID: 01X+R114QpeuD/ujH2BIGA== X-CSE-MsgGUID: orGq40fWT9WdBA7JUc3XJg== X-IronPort-AV: E=McAfee;i="6700,10204,11138"; a="19203979" X-IronPort-AV: E=Sophos;i="6.09,222,1716274800"; d="scan'208";a="19203979" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2024 17:00:11 -0700 X-CSE-ConnectionGUID: oI8TVU6KT4um5oZlVgTLPQ== X-CSE-MsgGUID: E8lOVbDmRJ24D6C40c4QhA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,222,1716274800"; d="scan'208";a="51902343" Received: from akshataa-mobl1.amr.corp.intel.com (HELO adixit-arch.intel.com) ([10.125.49.76]) by orviesa007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2024 17:00:10 -0700 Date: Fri, 19 Jul 2024 16:55:24 -0700 Message-ID: <87h6clc4yb.wl-ashutosh.dixit@intel.com> From: "Dixit, Ashutosh" To: Lucas De Marchi Cc: Joonas Lahtinen , Rodrigo Vivi , intel-xe@lists.freedesktop.org, Umesh Nerlige Ramappa , Jose Souza , dri-devel@lists.freedesktop.org, Thomas Hellstrom Subject: Re: When sysfs is not available (say containers) In-Reply-To: References: <20240618014609.3233427-1-ashutosh.dixit@intel.com> <20240618014609.3233427-6-ashutosh.dixit@intel.com> <871q3p5nsz.wl-ashutosh.dixit@intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-xe-bounces@lists.freedesktop.org Sender: "Intel-xe" On Fri, 19 Jul 2024 10:26:20 -0700, Lucas De Marchi wrote: > > On Fri, Jul 19, 2024 at 09:50:04AM GMT, Ashutosh Dixit wrote: > > On Mon, 17 Jun 2024 18:45:57 -0700, Ashutosh Dixit wrote: > >> > > > > Folks, > > > > The below is just an example from one of the earlier OA patches (already > > merged): > > > >> [PATCH 05/17] drm/xe/oa/uapi: Add/remove OA config perf ops > >> > >> +static ssize_t show_dynamic_id(struct kobject *kobj, > >> + struct kobj_attribute *attr, > >> + char *buf) > >> +{ > >> + struct xe_oa_config *oa_config = > >> + container_of(attr, typeof(*oa_config), sysfs_metric_id); > >> + > >> + return sysfs_emit(buf, "%d\n", oa_config->id); > >> +} > >> + > >> +static int create_dynamic_oa_sysfs_entry(struct xe_oa *oa, > >> + struct xe_oa_config *oa_config) > >> +{ > >> + sysfs_attr_init(&oa_config->sysfs_metric_id.attr); > >> + oa_config->sysfs_metric_id.attr.name = "id"; > >> + oa_config->sysfs_metric_id.attr.mode = 0444; > >> + oa_config->sysfs_metric_id.show = show_dynamic_id; > >> + oa_config->sysfs_metric_id.store = NULL; > >> + > >> + oa_config->attrs[0] = &oa_config->sysfs_metric_id.attr; > >> + oa_config->attrs[1] = NULL; > >> + > >> + oa_config->sysfs_metric.name = oa_config->uuid; > >> + oa_config->sysfs_metric.attrs = oa_config->attrs; > >> + > >> + return sysfs_create_group(oa->metrics_kobj, &oa_config->sysfs_metric); > >> +} > > > > So we often expose things in sysfs. The question is: are there general > > guidelines for what to do for environments (such as containers) where > > userspace cannot access sysfs? E.g. in such cases, do we expose the > > information exposed in sysfs via queries (i.e. an ioctl)? Or another way? > > What have we done in the past in drm and what should we do in these cases > > for Xe? > > userspace should be written in a way to handle sysfs potentially not > being around and not crash in that case. Providing limited functionality > is fine and user can decide what to do in that case. Creating > duplicate and alternative API to handle this is not a good solution IMO. > > For containers, it's common to mount sysfs read-only to give container > visibility on the host configuration... or parts of it in case you are > giving the container privilege over that part of the system. > > Related, on another project I maintain (kmod) including systemd folks: > https://github.com/kmod-project/kmod/issues/10 > > From https://systemd.io/CONTAINER_INTERFACE/: > > Make sure to pre-mount /proc/, /sys/, and /sys/fs/selinux/ before > invoking systemd, and mount /sys/, /sys/fs/selinux/ and /proc/sys/ > read-only (the latter via e.g. a read-only bind mount on itself) > > that page has more information on other parts of sysfs that people make > writable/readable for similar issues in other subsystems and is worth > reading. Thanks for the pointers Lucas, this helps :) Ashutosh