The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/7058
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) ===
From 4da15545086b3c1a67c1e2df35fe1be1390a905c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 18 Mar 2020 17:35:45 -0400 Subject: [PATCH 1/2] lxd/internal: Log some memory stats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd/api_internal.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lxd/api_internal.go b/lxd/api_internal.go index 1cbdcd79bc..66918da59f 100644 --- a/lxd/api_internal.go +++ b/lxd/api_internal.go @@ -30,6 +30,7 @@ import ( log "github.com/lxc/lxd/shared/log15" "github.com/lxc/lxd/shared/logger" "github.com/lxc/lxd/shared/osarch" + "github.com/lxc/lxd/shared/units" ) var apiInternal = []APIEndpoint{ @@ -747,6 +748,14 @@ func internalGC(d *Daemon, r *http.Request) response.Response { logger.Infof("Started forced garbage collection run") runtime.GC() runtimeDebug.FreeOSMemory() + + var m runtime.MemStats + runtime.ReadMemStats(&m) + logger.Infof("Heap allocated: %s", units.GetByteSizeString(int64(m.Alloc), 2)) + logger.Infof("Stack in use: %s", units.GetByteSizeString(int64(m.StackInuse), 2)) + logger.Infof("Requested from system: %s", units.GetByteSizeString(int64(m.Sys), 2)) + logger.Infof("Releasable to OS: %s", units.GetByteSizeString(int64(m.HeapIdle - m.HeapReleased), 2)) + logger.Infof("Completed forced garbage collection run") return response.EmptySyncResponse From 480a4d95b21c042e06bfde5f5f472e3a4bf301f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= <stgra...@ubuntu.com> Date: Wed, 18 Mar 2020 17:42:06 -0400 Subject: [PATCH 2/2] shared: Drop Pipe function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Graber <stgra...@ubuntu.com> --- lxd-agent/exec.go | 2 +- lxd/instance/drivers/driver_lxc.go | 2 +- lxd/instance_exec.go | 2 +- shared/util_linux_cgo.go | 28 ---------------------------- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/lxd-agent/exec.go b/lxd-agent/exec.go index f3e58ef90e..35310ffef2 100644 --- a/lxd-agent/exec.go +++ b/lxd-agent/exec.go @@ -237,7 +237,7 @@ func (s *execWs) Do(op *operations.Operation) error { ttys = make([]*os.File, 3) ptys = make([]*os.File, 3) for i := 0; i < len(ttys); i++ { - ptys[i], ttys[i], err = shared.Pipe() + ptys[i], ttys[i], err = os.Pipe() if err != nil { return err } diff --git a/lxd/instance/drivers/driver_lxc.go b/lxd/instance/drivers/driver_lxc.go index b9bf587897..2fdb761e12 100644 --- a/lxd/instance/drivers/driver_lxc.go +++ b/lxd/instance/drivers/driver_lxc.go @@ -5601,7 +5601,7 @@ func (c *lxc) Exec(req api.InstanceExecPost, stdin *os.File, stdout *os.File, st } // Setup communication PIPE - rStatus, wStatus, err := shared.Pipe() + rStatus, wStatus, err := os.Pipe() defer rStatus.Close() if err != nil { return nil, err diff --git a/lxd/instance_exec.go b/lxd/instance_exec.go index 8f3e3d41a0..7107467ab3 100644 --- a/lxd/instance_exec.go +++ b/lxd/instance_exec.go @@ -132,7 +132,7 @@ func (s *execWs) Do(op *operations.Operation) error { ttys = make([]*os.File, 3) ptys = make([]*os.File, 3) for i := 0; i < len(ttys); i++ { - ptys[i], ttys[i], err = shared.Pipe() + ptys[i], ttys[i], err = os.Pipe() if err != nil { return err } diff --git a/shared/util_linux_cgo.go b/shared/util_linux_cgo.go index 41d84b80ff..69c9be5534 100644 --- a/shared/util_linux_cgo.go +++ b/shared/util_linux_cgo.go @@ -99,18 +99,6 @@ void create_pty(int *master, int *slave, uid_t uid, gid_t gid) { } } -void create_pipe(int *master, int *slave) { - int pipefd[2]; - - if (pipe2(pipefd, O_CLOEXEC) < 0) { - fprintf(stderr, "Failed to create a pipe: %s\n", strerror(errno)); - return; - } - - *master = pipefd[0]; - *slave = pipefd[1]; -} - int get_poll_revents(int lfd, int timeout, int flags, int *revents, int *saved_errno) { int ret; @@ -174,22 +162,6 @@ func OpenPty(uid, gid int64) (master *os.File, slave *os.File, err error) { return master, slave, nil } -func Pipe() (master *os.File, slave *os.File, err error) { - fd_master := C.int(-1) - fd_slave := C.int(-1) - - C.create_pipe(&fd_master, &fd_slave) - - if fd_master == -1 || fd_slave == -1 { - return nil, nil, errors.New("Failed to create a new pipe") - } - - master = os.NewFile(uintptr(fd_master), "master") - slave = os.NewFile(uintptr(fd_slave), "slave") - - return master, slave, nil -} - // UserId is an adaption from https://codereview.appspot.com/4589049. func UserId(name string) (int, error) { var pw C.struct_passwd
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel