Skip to content

Commit

Permalink
Merge pull request #244 from fromanirh/consume-snapshot-gpu
Browse files Browse the repository at this point in the history
gpu: pass through the context into subsystems
  • Loading branch information
jaypipes authored May 11, 2021
2 parents b8b1e31 + 4e17fb3 commit 5ebee3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pkg/gpu/gpu_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ func (i *Info) load() error {
cards = append(cards, card)
}
gpuFillNUMANodes(i.ctx, cards)
gpuFillPCIDevice(cards)
gpuFillPCIDevice(i.ctx, cards)
i.GraphicsCards = cards
return nil
}

// Loops through each GraphicsCard struct and attempts to fill the DeviceInfo
// attribute with PCI device information
func gpuFillPCIDevice(cards []*GraphicsCard) {
pci, err := pci.New()
func gpuFillPCIDevice(ctx *context.Context, cards []*GraphicsCard) {
pci, err := pci.NewWithContext(ctx)
if err != nil {
return
}
Expand All @@ -117,7 +117,7 @@ func gpuFillPCIDevice(cards []*GraphicsCard) {
// system is not a NUMA system, the Node field will be set to nil.
func gpuFillNUMANodes(ctx *context.Context, cards []*GraphicsCard) {
paths := linuxpath.New(ctx)
topo, err := topology.New()
topo, err := topology.NewWithContext(ctx)
if err != nil {
// Problem getting topology information so just set the graphics card's
// node to nil
Expand Down
8 changes: 7 additions & 1 deletion pkg/pci/pci.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,13 @@ func (i *Info) String() string {
// New returns a pointer to an Info struct that contains information about the
// PCI devices on the host system
func New(opts ...*option.Option) (*Info, error) {
ctx := context.New(opts...)
return NewWithContext(context.New(opts...))
}

// NewWithContext returns a pointer to an Info struct that contains information about
// the PCI devices on the host system. Use this function when you want to consume
// the topology package from another package (e.g. gpu)
func NewWithContext(ctx *context.Context) (*Info, error) {
// by default we don't report NUMA information;
// we will only if are sure we are running on NUMA architecture
arch := topology.ARCHITECTURE_SMP
Expand Down

0 comments on commit 5ebee3b

Please sign in to comment.