--- /dev/null
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * Copyright (C) Samsung Electronics, 2018
+ *
+ * 2018 Vyacheslav Cherkashin <v.cherkashin@samsung.com>
+ *
+ */
+
+
+#include <linux/bug.h>
+#include <linux/errno.h>
+#include <linux/cpuhotplug.h>
+#include "kernel_operations.h"
+
+
+static int dyn_state;
+
+int cpu_notifier_start(int (*cpu_setup)(unsigned int cpu),
+ int (*cpu_shutdown)(unsigned int cpu))
+{
+ int ret;
+ BUG_ON(dyn_state != 0);
+
+ ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "swap/sampler:online",
+ cpu_setup, cpu_shutdown);
+ if (ret < 0) {
+ print_err("Cannot allocate dynamic state, ret=%d\n", ret);
+ return ret;
+ }
+
+ dyn_state = ret;
+ return 0;
+}
+
+void cpu_notifier_stop(void)
+{
+ BUG_ON(dyn_state <= 0);
+
+ cpuhp_remove_state(dyn_state);
+ dyn_state = 0;
+}