Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752126AbbHRAW0 (ORCPT ); Mon, 17 Aug 2015 20:22:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58659 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751989AbbHRAWV (ORCPT ); Mon, 17 Aug 2015 20:22:21 -0400 Date: Mon, 17 Aug 2015 21:20:50 -0300 From: Marcelo Tosatti To: Vikas Shivappa Cc: Matt Fleming , Tejun Heo , Vikas Shivappa , linux-kernel@vger.kernel.org, x86@kernel.org, hpa@zytor.com, tglx@linutronix.de, mingo@kernel.org, peterz@infradead.org, matt.fleming@intel.com, will.auld@intel.com, glenn.p.williamson@intel.com, kanaka.d.juvva@intel.com, Karen Noel Subject: Re: [PATCH 5/9] x86/intel_rdt: Add new cgroup and Class of service management Message-ID: <20150818002050.GA3744@amt.cnet> References: <1435789270-27010-1-git-send-email-vikas.shivappa@linux.intel.com> <1435789270-27010-6-git-send-email-vikas.shivappa@linux.intel.com> <20150730194458.GD3504@mtj.duckdns.org> <20150802163157.GB32599@mtj.duckdns.org> <20150805122257.GD4332@codeblueprint.co.uk> <20150806002404.GA24422@amt.cnet> <20150807131506.GA6649@amt.cnet> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150807131506.GA6649@amt.cnet> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3955 Lines: 115 Vikas, Tejun, This is an updated interface. It addresses all comments made so far and also covers all use-cases the cgroup interface covers. Let me know what you think. I'll proceed to writing the test applications. Usage model: ------------ This document details how CAT technology is exposed to userspace. Each task has a list of task cache reservation entries (TCRE list). The init process is created with empty TCRE list. There is a system-wide unique ID space, each TCRE is assigned an ID from this space. ID's can be reused (but no two TCREs have the same ID at one time). The interface accomodates transient and independent cache allocation adjustments from applications, as well as static cache partitioning schemes. Allocation: Usage of the system calls require CAP_SYS_CACHE_RESERVATION capability. A configurable percentage is reserved to tasks with empty TCRE list. On fork, the child inherits the TCR from its parent. Semantics: Once a TCRE is created and assigned to a task, that task has guaranteed reservation on any CPU where its scheduled in, for the lifetime of the TCRE. A task can have its TCR list modified without notification. FIXME: Add a per-task flag to not copy the TCR list of a task but delete all TCR's on fork. Interface: enum cache_rsvt_flags { CACHE_RSVT_ROUND_DOWN = (1 << 0), /* round "kbytes" down */ }; enum cache_rsvt_type { CACHE_RSVT_TYPE_CODE = 0, /* cache reservation is for code */ CACHE_RSVT_TYPE_DATA, /* cache reservation is for data */ CACHE_RSVT_TYPE_BOTH, /* cache reservation is for code and data */ }; struct cache_reservation { unsigned long kbytes; int type; int flags; int trcid; }; The following syscalls modify the TCR of a task: * int sys_create_cache_reservation(struct cache_reservation *rsvt); DESCRIPTION: Creates a cache reservation entry, and assigns it to the current task. returns -ENOMEM if not enough space, -EPERM if no permission. returns 0 if reservation has been successful, copying actual number of kbytes reserved to "kbytes", type to type, and tcrid. * int sys_delete_cache_reservation(struct cache_reservation *rsvt); DESCRIPTION: Deletes a cache reservation entry, deassigning it from any task. Backward compatibility for processors with no support for code/data differentiation: by default code and data cache allocation types fallback to CACHE_RSVT_TYPE_BOTH on older processors (and return the information that they done so via "flags"). * int sys_attach_cache_reservation(pid_t pid, unsigned int tcrid); DESCRIPTION: Attaches cache reservation identified by "tcrid" to task by identified by pid. returns 0 if successful. * int sys_detach_cache_reservation(pid_t pid, unsigned int tcrid); DESCRIPTION: Detaches cache reservation identified by "tcrid" to task by identified pid. The following syscalls list the TCRs: * int sys_get_cache_reservations(size_t size, struct cache_reservation list[]); DESCRIPTION: Return all cache reservations in the system. Size should be set to the maximum number of items that can be stored in the buffer pointed to by list. * int sys_get_tcrid_tasks(unsigned int tcrid, size_t size, pid_t list[]); DESCRIPTION: Return which pids are associated to tcrid. * sys_get_pid_cache_reservations(pid_t pid, size_t size, struct cache_reservation list[]); DESCRIPTION: Return all cache reservations associated with "pid". Size should be set to the maximum number of items that can be stored in the buffer pointed to by list. * sys_get_cache_reservation_info() DESCRIPTION: ioctl to retrieve hardware info: cache round size, whether code/data separation is supported. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/