Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions include/tscore/ink_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ countof(const T (&)[N])
#define unlikely(x) __builtin_expect(!!(x), 0)
#endif

#if TS_USE_HWLOC
#include <hwloc.h>
#endif

#if defined(MAP_NORESERVE)
#define MAP_SHARED_MAP_NORESERVE (MAP_SHARED | MAP_NORESERVE)
#else
Expand All @@ -119,7 +115,6 @@ extern int on;
/* Functions
*/
int ink_sys_name_release(char *name, int namelen, char *release, int releaselen);
int ink_number_of_processors();
int ink_login_name_max();

#ifdef __cplusplus
Expand All @@ -136,8 +131,3 @@ ROUNDUP(ArithmeticV value, ArithmeticM m)
return value;
}
#endif

#if TS_USE_HWLOC
// Get the hardware topology
hwloc_topology_t ink_get_topology();
#endif
33 changes: 33 additions & 0 deletions include/tscore/ink_hw.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/** @file

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include "tscore/ink_config.h"

#if TS_USE_HWLOC
#include <hwloc.h>

// Get the hardware topology
hwloc_topology_t ink_get_topology();
#endif

int ink_number_of_processors();
3 changes: 2 additions & 1 deletion iocore/aio/AIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
* Async Disk IO operations.
*/

#include <tscore/TSSystemState.h>
#include "tscore/TSSystemState.h"
#include "tscore/ink_hw.h"

#include "P_AIO.h"

Expand Down
1 change: 1 addition & 0 deletions iocore/aio/test_AIO.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "P_AIO.h"
#include "InkAPIInternal.h"
#include "tscore/ink_hw.h"
#include "tscore/I_Layout.h"
#include "tscore/TSSystemState.h"
#include "tscore/Random.h"
Expand Down
1 change: 1 addition & 0 deletions iocore/eventsystem/UnixEventProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <hwloc.h>
#endif
#include "tscore/ink_defs.h"
#include "tscore/ink_hw.h"
#include "tscore/hugepages.h"

/// Global singleton.
Expand Down
3 changes: 3 additions & 0 deletions iocore/net/test_I_Net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
*/

#include "P_Net.h"

#include "tscore/ink_hw.h"

#include <netdb.h>

#include "diags.i"
Expand Down
4 changes: 4 additions & 0 deletions src/traffic_layout/info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
#include "RecordsConfig.h"
#include "info.h"

#if TS_USE_HWLOC
#include <hwloc.h>
#endif

#if HAVE_ZLIB_H
#include <zlib.h>
#endif
Expand Down
1 change: 1 addition & 0 deletions src/traffic_server/traffic_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "tscore/ink_platform.h"
#include "tscore/ink_sys_control.h"
#include "tscore/ink_args.h"
#include "tscore/ink_hw.h"
#include "tscore/ink_lockfile.h"
#include "tscore/ink_stack_trace.h"
#include "tscore/ink_syslog.h"
Expand Down
1 change: 1 addition & 0 deletions src/tscore/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ libtscore_la_SOURCES = \
ink_error.cc \
ink_file.cc \
ink_hrtime.cc \
ink_hw.cc \
ink_inet.cc \
ink_memory.cc \
ink_mutex.cc \
Expand Down
48 changes: 0 additions & 48 deletions src/tscore/ink_defs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,32 +41,6 @@
int off = 0;
int on = 1;

#if TS_USE_HWLOC

#include <hwloc.h>

// Little helper to initialize the hwloc topology, once.
static hwloc_topology_t
setup_hwloc()
{
hwloc_topology_t topology;

hwloc_topology_init(&topology);
hwloc_topology_load(topology);

return topology;
}

// Get the topology
hwloc_topology_t
ink_get_topology()
{
static hwloc_topology_t topology = setup_hwloc();
return topology;
}

#endif

int
ink_sys_name_release(char *name, int namelen, char *release, int releaselen)
{
Expand Down Expand Up @@ -117,28 +91,6 @@ ink_sys_name_release(char *name, int namelen, char *release, int releaselen)
#endif
}

int
ink_number_of_processors()
{
#if TS_USE_HWLOC
#if HAVE_HWLOC_OBJ_PU
return hwloc_get_nbobjs_by_type(ink_get_topology(), HWLOC_OBJ_PU);
#else
return hwloc_get_nbobjs_by_type(ink_get_topology(), HWLOC_OBJ_CORE);
#endif
#elif defined(freebsd)
int mib[2], n;
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
size_t len = sizeof(n);
if (sysctl(mib, 2, &n, &len, nullptr, 0) == -1)
return 1;
return n;
#else
return sysconf(_SC_NPROCESSORS_ONLN); // number of processing units (includes Hyper Threading)
#endif
}

int
ink_login_name_max()
{
Expand Down
70 changes: 70 additions & 0 deletions src/tscore/ink_hw.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/** @file

@section license License

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "tscore/ink_hw.h"
#include "tscore/ink_platform.h"

#if TS_USE_HWLOC

#include <hwloc.h>

// Little helper to initialize the hwloc topology, once.
static hwloc_topology_t
setup_hwloc()
{
hwloc_topology_t topology;

hwloc_topology_init(&topology);
hwloc_topology_load(topology);

return topology;
}

// Get the topology
hwloc_topology_t
ink_get_topology()
{
static hwloc_topology_t topology = setup_hwloc();
return topology;
}

int
ink_number_of_processors()
{
#if TS_USE_HWLOC
#if HAVE_HWLOC_OBJ_PU
return hwloc_get_nbobjs_by_type(ink_get_topology(), HWLOC_OBJ_PU);
#else
return hwloc_get_nbobjs_by_type(ink_get_topology(), HWLOC_OBJ_CORE);
#endif
#elif defined(freebsd)
int mib[2], n;
mib[0] = CTL_HW;
mib[1] = HW_NCPU;
size_t len = sizeof(n);
if (sysctl(mib, 2, &n, &len, nullptr, 0) == -1)
return 1;
return n;
#else
return sysconf(_SC_NPROCESSORS_ONLN); // number of processing units (includes Hyper Threading)
#endif
}
#endif
1 change: 1 addition & 0 deletions src/tscore/unit_tests/freelist_benchmark.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "catch.hpp"

#include "tscore/ink_hw.h"
#include "tscore/ink_thread.h"
#include "tscore/ink_memory.h"
#include "tscore/ink_queue.h"
Expand Down